https://www.spoj.com/problems/APS/ why my code is not executing?

  1. #include<bits/stdc++.h>

  2. using namespace std;

  3. #define n 10000000

  4. typedef long long int ll;

  5. ll a[n+5];

  6. ll s[n+5];

  7. void leastp(){

  8. for(int i=0;i<n;i++){

  9. a[i]=0;}

  10. for(int i=2;i<n;i++){

  11. if(a[i]==0)

  12. a[i]=i;

  13. for(int j=i*i;j<n;j+=i)

  14. if(a[j]==0)

  15. a[j]=i;

  16. }

  • s[0]=0;
  1. s[1]=0;

  2. ll ans=0;

  3. for(int i=2;i<n;i++){

  4. s[i]=ans+a[i];

  5. ans=s[i];

  6. }

  • }

  • int main(){

  1. leastp();

  2. int t;

  3. cin>>t;

  4. while(t–){

  5. ll x;

  6. cin>>x;

  7. cout<<s[x]<<endl;

  8. }

  9. }