Блог пользователя DMGR

Автор DMGR, история, 8 лет назад, По-английски

For some number theory problems like finding Euler Totient Function for some number N,the method involves multiplying N by (1-1/p) for all primes p which divide N. This takes care of Inclusion Exclusion step as all additions/subtractions correspond to Inclusion/Exclusion step. However if the problem is modified to finding all numbers below K which are coprime to N, we cannot directly carry on the multiplications as some of the primes may not divide K completely and instead of this we have to carry on Integer divisions corresponding to each combination of prime divisors of N(2^x,if x prime divisors). So the solution which was linear in number of prime divisors is rendered exponential. Is their someway around this complication.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +4
  • Проголосовать: не нравится

Автор DMGR, 9 лет назад, По-английски

I was solving this problem from Round 240 Div 2.

415D - Mashmokh and ACM

I wrote this code on Ideone Code Link .However when I submitted it on codeforces I got WA on 4th test case which was "1478 194" with answer "312087753" and my output "285334421". When I gave this input to my ideone code,I got the right answer "312087753". But when I tried it with custom invocation of codeforces ,I got the wrong answer again, "285334421". Is their something different between ideone compilers and codeforces compilers.What can I do get to get correct answer on codeforces?

PS- Ideone code was compiled with C++14 and codeforces with C++11 .Is that the issue somehow?

Полный текст и комментарии »

  • Проголосовать: нравится
  • -11
  • Проголосовать: не нравится