Codeforces celebrates 10 years! We are pleased to announce the crowdfunding-campaign. Congratulate us by the link https://codeforces.com/10years. ×

rprudhvi590's blog

By rprudhvi590, history, 3 months ago, In English,
  • Given an integer n, find and return the n'th magic number
  • A magic number is defined as a number which can be expressed as a power of 7 or sum of unique powers of 7
  • First four magic numbers are  7 ,  49 ,  56 (7 + 49),  343,etc . constraint 1<=n<=pow(10,18) i have implemented the solution as follows:

https://ideone.com/Q8OM0b but it gives me wrong answer,the only difference is that when calculating the value of add we need to apply mod;and the solution is as follows:

https://ideone.com/k1KhFA

how will we know where to apply a mod operator..pls help.

Read more »

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

By rprudhvi590, history, 4 months ago, In English,
 
 
 
 
  • Vote: I like it
  • -2
  • Vote: I do not like it