Comments
+5

That's not a counterexample to greedy but rather to either not handling overflows or 0's correctly. Also, greedy does work.

0

Did you handle overflows?

+7

Dang you are a cool guy

On thesilioneNeed Hints, 11 years ago
+5

Can you explain the motivation behind of using this inversion operation and also why simply using this operation is correct?

This problem can be done in O(m+n) you don't need BIT

On WoreviamPC^2 online, 12 years ago
+1

why not just use PC^2

On lovro-sindaLaw — number, 12 years ago
0

not sure though

On lovro-sindaLaw — number, 12 years ago
0

Since A,B <= 10^9, there are only 2^9 different numbers consisting of only 3's and 5's. Precalculate these and put into a list, making sure that you do not put a number that is divisible by any of the numbers already in the list.

Let F(A) = # of law numbers in the interval [1,A]. Then we seek F(B)-F(A-1).

F(X) can be calculated as follows: for i = 0 ... size(list) d = list[i], ans+= X/d-F(X/d) ; return ans;

yes

same for me

On e19-unUSACO, 12 years ago
+3

Same algorithm I came up with too.