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

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

problem MEXUM(problem_link)

My sol(sol_link) is giving WA. I could not figure out, why is this happening. Someone please help me find out the error.

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

»
5 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by manoj9april (previous revision, new revision, compare).

»
5 лет назад, # |
Rev. 3   Проголосовать: нравится +5 Проголосовать: не нравится

In your code, I found these three lines will get overflow.

line 111 -> ans = (ans + (i*(mul*po2[n-sum])%mod)%mod )%mod;

line 114 -> ans = (ans + (i*(mul*po2[n-sum])%mod)%mod )%mod;

line 119 -> mul = (mul * (po2[fre[i]]-1+mod)%mod)%mod;

I changed these three lines as follow and got AC:

line 111 -> ans = (ans + (i*((mul*po2[n-sum])%mod))%mod )%mod;

line 114 -> ans = (ans + (i*((mul*po2[n-sum])%mod))%mod )%mod;

line 119 -> mul = (mul * ((po2[fre[i]]-1+mod)%mod))%mod;

(a*(b*c)%mod)%mod is equivalent to (a*b*c)%mod. Sorry for my bad English, Hope this will help you in the future.

your modified code solution link: https://www.codechef.com/viewsolution/32300055