Static Perfect Hashing – FKS

I am trying to understand perfect hashing aka FKS, but I have a few questions.

From my understanding, perfect hashing is a two level hashing in which you take a hash function from a universal family of hash functions, and hash a key to a specific slot in a hash table. At this step there might be collisions and that’s why we apply a second hash function to the key and we store as the value another hash table of size at most 2n.

My questions are:

  1. Do we have two hash tables? Can we have 1 array and 1 hash table?
  2. Can the 2 hash functions used have different inputs? Meaning can I pass different keys to each hash function?

For example, I have a string and I would like to store it in a dictionary using static perfect hashing. Can I do the following? :

  1. Have a hash table (A) that will store a counter that will be incremented and will be at max n. The counter will be used as the index where the string starts, for example, if the string is “hello”, and the counter= 2, the string will be modified and started from index 2, so the string will be “llo”. Therefore A will be of size n and will have as keys the counter, and as values it will have hash tables (B_i).

    Then B_i will store as keys the character of the string and as values the position of each character with regards of the counter.

  2. Have a hash function that will be used to map the position of the character in the string to a specific slot in the hash table (A)
  3. Have a second hash function that will map each character in the string to a slot in the second hash table B_i.

Is that a valid way of performing static perfect hashing? Could I remove the first hash function and turn the first hash table (A) into a simple array (since at the first stage I am only interested in the index/position of the characters in the string?

enter image description here

Count number of pairs of elements whose product is a perfect square

Given two arrays whose elements lie between $ [1,10^5]$ and the size of arrays is $ [1,10^5]$ , how can we find the total number of pairs of elements from these arrays such that their product is a perfect square? The arrays may have same elements.

For example:

Array 1: {1, 2, 4, 5}

Array 2: {4, 8, 16, 125}

Output : 6

The pairs are (1, 4), (1, 16), (2, 8), (4, 4), (4, 16), (5, 125).

If the array size is $ 10^5$ , an $ n^2$ algorithm would be inefficient.

Quick Sale / Specific Niche / Perfect for Car Dealership Owners

Hey guys,

Selling my website: Reselling / selling Carfax reports.

This is best for those who own a car dealership in the US or EU and who get Carfax unlimited reports.

Or you can always find someone who sells Carfax for cheap and re-sell it.

#10 Position in Google – Keyword "Cheap Carfax"

You can also re-sell AutoCheck reports. I can give you a supplier who sells it for $ 2.

October 2November 2

Total: $ 198 – 33 Orders ($ 5.99)

August 30 -…

Quick Sale / Specific Niche / Perfect for Car Dealership Owners

Can a Magus Kensai Use Perfect Strike Multiple Times on a Crit?

The Perfect Strike ability states:

At 4th level, when a kensai hits with his chosen weapon, he can spend 1 point from his arcane pool in order to maximize his weapon damage. Don’t roll for damage—the weapon deals maximum damage. This affects only the weapon’s base damage dice, not additional damage from sneak attack, magical weapon properties, spellstrike, or critical hits. If the kensai confirms a critical hit, he can instead spend 2 points from his arcane pool to increase his weapon’s critical multiplier by 1.

However there is nothing on the table of bonuses that effect crit multipliers or even says that it is a bonus in the first place. Can the Kensai use perfect strike multiple times to continuously increase the crit multiplier?

Mobile Phones And Mobile Broadband – The Secrets Of Choosing The Perfect Deal

How exactly do you choose the perfect mobile phone deal? Or mobile broadband? Join me, as I show you buy phone list!
Let’s face it, if you’re trying to find yourself a new mobile phone, or if you’re trying to get yourself that perfect mobile broadband deal, it can be a bit of a minefield. You have to factor in the tariff, how many minutes you get, how many texts, whether you get international roaming… well, the list goes on. But the thing is, it doesn’t have to be a minefield. It can actually be really, really easy. Like anything, though, it takes a bit of preparation. You need to get your mind straight, and then everything else will follow on from that. There’s no point running in half-cocked, and buying a mobile phone or a mobile broadband package, purely on the spur of the moment. Otherwise you’ll get buyer’s remorse, and you won’t enjoy your purchase. Like anything in life, prepare, prepare, prepare!
Step 1 – Analyse what you really want from your new deal
Ok, it sounds obvious, and it sounds silly, but you’d be amazed how many people don’t do this. You need to ask yourself: ‘What factors determine that I need a new mobile phone or mobile broadband? What benefits do I want to get from my new gadget? How am I going to use it?’ In essence, sit down and follow this rough guideline:
– How many minutes-worth of calls do I, or will I, make per month?
– How many text messages do I send per month?
– Do I need to send photo messages?
– Do I need internet access? If I do, might I be better off getting a mobile broadband package?
– How much am I willing to (or can afford to) pay every month?
Only when you’ve answered those questions in your mind should you move on to step 2.
Step 2 – Choosing the right handset
This is the bit that traditionally is the hardest. You know, now, what deal you want, but have you decided on a phone? As before, don’t just buy the first one you find! Fortunately, you have a tool on your side, here: comparison sites (think along the lines of MobileShop, Pricerunner, or Kelkoo). They list everything you ca buy, and will let you search under various criteria, like price, how many minutes and so on. So, go on to one of them, armed with the knowledge you have from Step 1, and start searching. Once you filled in what you want from the deal, no doubt lots of mobile phones or mobile broadband packages will come back.
Now, the next bit of advice may sound contrary, but basically… once you have fed in the details of what you want from the deal, the comparison site will bring back handsets that match that deal. So, you know that whatever you’re now seeing is within your range of options. Once you know that, it lets you move onto the next step with confidence…
Step 3 – Choose from the heart!
Now that you’ve made all the logical choices about what you need, you have a list of mobile phones and mobile broadband packages that fit your needs. So, now, you can choose a handsets based on what you want, on how the handset looks, or how you like the feel of it, or the fact it’s got a massive camera, or the fact that it plays back 93 billion different types of music. Or if you’re looking at mobile broadband, how it can run at speeds of 300 Megamassivemungabits per second!
You see, this is why you made all the important choices early on. This is why you did all the boring ‘what do I really need?’ stuff right at the start. You did it so that NOW, you can jump in and grab whatever mobile phones catch your eye, whatever mobile broadband package says, to you, ‘Buy me!’ And voila, before you know it, you’ll have bought the perfect deal!


Images look bad with perfect paragraph width

I’m working on a WordPress template and trying to maintain perfect line width of ~70 characters. My blog has a lot of posts and most of the post contain at least one image per paragraph, usually more. So the site is quite media-heavy.

1. BAD

enter image description here

Screenshot above shows post content view with wrapper set to be 1140px wide, it’s extremely hard to read as there are up to 150 characters per line. Maybe at first everything looks a-okay but in reality it’s extremely tiring to read only after a few lines.

2. GOOD (?)

enter image description here

And here paragraphs are squashed to 700px what gives quite pleasant 50-80 characters per line.

In my opinion it looks quite alright but I’m not sure if it’s okay if the images are so much wider than text (they’re still at 1140px)? It looks fine at first but when I’m scrolling through 10 images per post my eyes are jumping from the middle of the page (text) to the left (images) and that’s becomes irritating quickly. Or maybe I’m overreacting and everything is in order?

3. MIXED (?)

enter image description here

Justifying the text might help here a little but nobody wants to read justified text. Also I feel like the images are way too small a 700px width, everything looks really compressed. I think it might be even worse than point 1, but I’m not sure.

My question is – how to tackle this issue? Is number 2 okay in your opinion? Maybe I should change something? Typography is really hard and any hints would be highly appreciated!

Find $n’th$ perfect number , where perfect number is a positive integer whose sum of digits is $10$

For example $ 46$ is a perfect number , since $ 4+6=10$ . If $ n=1$ , answer is $ 19$ . If $ n=2$ , answer is $ 28$ . If $ n=3$ , answer is $ 37$ and so on .We need to make a program which takes $ n$ and outputs $ n’th$ perfect number.

How to solve this problem for large $ n$ , for example $ n$ close to $ 10^{18}$ ? we can’t use brute force method since input can be so large .Can we solve it using DP or binary search ?

Source of the problem : Perfect Number

Note: In given problem statement (in link) $ n$ is not large and thus can be solved using brute force.But i am curious to solve it for large $ n$ .