Submit | All submissions | Best solutions | Back to list |
INTEGER1 - Power of Integer |
For a given positive integer y (y > 1), if we can find a largest integer k and a smallest positive integer x, such that x^k=y, then the power of y is regarded as k.
Calculate the sum of the power of the integers from a to b. (2<= a <= b <=1018)
Input
The input consists of multiple test cases.
For each test case, there is one line containing two integers a and b.
End of input is indicated by a line containing two zeros.
Output
For each test case, output the sum of the power of the integers from a to b.
Example
Input: 2 10 248832 248832 0 0 Output: 13 5
Added by: | Fudan University Problem Setters |
Date: | 2009-05-23 |
Time limit: | 2s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: C99 ERL JS-RHINO NODEJS PERL6 VB.NET |
Resource: | Fudan University Local Contest #1 |
hide comments
2019-12-23 02:17:30 DK...
Im done with this problem, i tried several ways to solve it, but all of them got WA. Even I used python to avoid overflows, but in the end all my solutions got WA. |
|
2018-07-09 14:09:13 eagle93
I don't know why this happened, but the same code gets AC with C++ 4.3.2, but WA with CPP14, really strange!! |
|
2017-02-08 18:45:03
giving me WA over and over..dont know where it is wrong,,tested over different test cases from toolkit,,passed all but still,,,,,,, my ans for 2 , 1000000000000000000 is 1000000001002087980,,someone plz hlp.. Last edit: 2017-02-08 18:49:57 |
|
2014-07-16 08:32:06 Naman Goyal
Great problem. You can use long double calculation for finding nth root for initial guess and then correct it with INT 64 verification. For INT 64 verification take care of overflows. |
|
2013-05-24 12:04:09 wisfaq
Totally ununderstandable why such a nice and doable problem has so few accepted solutions. Last edit: 2013-05-24 18:48:55 |
|
2012-09-10 09:14:38 Harshit Agrawal
I am getting WA but could not find any test case for that. what is the answer for a=2 and b=1000000000000000000 ? My answer is 1000000001002087980. Please help ! |
|
2012-09-02 11:19:07 (Tjandra Satria Gunawan)(曾毅昆)
use double --> TLE use int --> WA use long long --> AC Nice problem :-) |
|
2011-07-13 11:52:18 cprocoder
Really very nice problem |
|
2011-04-09 19:33:39 sandeep pandey
Really nice problem. Thanks XilinX for adding such a thriling task. Last edit: 2013-11-21 18:20:44 |
|
2010-03-30 18:07:02 P != NP
don't use doubles or long doubles for this question....it will give WA. Use only long long int. Last edit: 2010-03-30 18:07:44 |