Master0fPuppets's blog

By Master0fPuppets, history, 2 months ago, In English

I can't find what is wrong with this code

My idea is I store the prime factors of x in a set and then I iterate through each (i) in the set and each time I calculate the number of numbers which are divisible by (i power k) and that is gonna be the number of times this number is going to contribute to the answer. the code passes the first 2 samples but the last one it doesn't so could anyone tell me what could be the problem in my code?

Problem:https://codeforces.com/contest/1228/problem/C

code:https://ideone.com/tkQZ4L

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

»
2 months ago, # |
  Vote: I like it 0 Vote: I do not like it

You need to substract the contribution of the higher powers first.

this is my code 124067958

  • »
    »
    2 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    u mean if we find 2 in the set we have to subtract (n / 2 power k+1) from (n / 2 power k) and that is the number (2 power k) that contributes to the answer?

    • »
      »
      »
      2 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      No, the contribution of some power isn't simply (n / x^power), you can see in my code I store this contribution in some map and simply subtract it.

      • »
        »
        »
        »
        2 months ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        i am sorry but can u explain the last for loop in ur code cuz i still dont get it