Problem : HS08PAUL - A conjecture of Paul Erdős
My code is giving output ;
0
1
2
13415
Code:
vector<bool> prime(10000000, true);
void primesieve(){
prime[0] = false;
prime[1] = false;
for (ll i = 2; i * i < 10000000; i++)
{
if (prime[i] == true)
{
for (ll j = i * i; j < 10000000; j = j + i)
{
prime[j] = false;
}
}
}
}
void chal() {
ll n;
cin>>n;
// cout<<n<<" ";
ll ans=0;
for(ll i=1;(i*i)<n;i++){
ll x=(i*i);
for(ll j=1;(j*j*j*j)<n;j++){
ll y=(j*j*j*j);
if((x+y)<=n){
if(prime[(x+y)]){
ans++;
}
}else{
break;
}
}
}
cout<<ans<<endl;
}
int32_t main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
srand(chrono::high_resolution_clock::now().time_since_epoch().count());
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
freopen("Error.txt", "w", stderr);
#endif
ll t;t = 1;
// cout << "Chal Raha Ho Ma";
cin>>t;
primesieve();
for (ll i = 1; i <= t; i++) {
chal();
}
return 0;
}
Why last output is differnt help in debuging?