andreyDagger's blog

By andreyDagger, history, 2 weeks ago, In English

WTF, lol, How is this problem 2000 difficulty? https://codeforces.com/problemset/problem/1919/H

Full text and comments »

  • Vote: I like it
  • +37
  • Vote: I do not like it

By andreyDagger, 14 months ago, In English

Let $$$m$$$ be some positive integer (not necessary prime) . There is a way to calculate $$$\displaystyle{\frac{a}{b}}\%m$$$ when b is not very big and $$$a \% b = 0$$$ Firstly, let's notice, that $$$\displaystyle{\frac{a}{b}}=mk+(a/b)\%m$$$, for some integer value k. Now, let's do some mathematical stuff:

$$$\displaystyle{\frac{a}{b}}=mk+\displaystyle{\frac{a}{b}}\%m$$$
$$$a=mbk+b(\displaystyle{\frac{a}{b}}\%m)$$$
$$$(a\%mb)=b(\displaystyle{\frac{a}{b}}\%m)$$$
$$$(a\%mb)/b=\displaystyle{\frac{a}{b}}\%m$$$

So, the answer is $$$(a\%mb)/b$$$

Full text and comments »

  • Vote: I like it
  • +17
  • Vote: I do not like it