We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Project Euler #29: Distinct powers
Project Euler #29: Distinct powers
Sort by
recency
|
47 Discussions
|
Please Login in order to post a comment
include
include
include
include
include
include
using namespace std;
int main() { set terms; long n; cin>>n; for(long a = 2; a <= n; a++){ for(long b = 2; b <= n; b++){ long result = pow(a, b); terms.insert(result); } } long count=0; for(long term : terms){ count++; } cout<
Can anyone explain what's wrong in my code? Only sample test case 0 successfully ran, and all remaining test cases were unsuccessful."
1.pow function cannot be user the answer is very large like (10^5)^(10^5) this is max and it cannot be stored in any data type like :int,long 2.and the elements aree so many that set cannot handle.memory error
I used the same principle in my code. But this only passes the first six test cases - timing out on the rest :-(
I cannot able to understand these problem