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.
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
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Join us
Create a HackerRank account
Be part of a 26 million-strong community of developers
Please signup or login in order to view this challenge
Project Euler #29: Distinct powers
You are viewing a single comment's thread. Return to all comments →
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