ALICE AND TOTIENT test case 2,3, not runting

help me out this
there is my code : ALICE AND TOTIENT

#include<iostream>
#include<cstring>
#include<vector>
#define N 1000002
using namespace std;

long arr[N];

void sieves(){
    // arr.reserve(N);
    memset(arr,0,sizeof(arr));
    for(long i=2 ; i<N ; i += 2){
        arr[i]=2;
    }
    for(long i = 3 ; i < N ; i += 2){
        if(arr[i] == 0){
            arr[i] = i;
            for(long j = i*i ; j < N ; j += 2*i)
                arr[j] = i;
        }
    }
    
}
int main(){
    long t,temp;
    long long totient;
    sieves();
    // for(int i=0;i<100;i++)
        // cout<<arr[i]<<" ";
    // cout<<'\n';
    cin>>t;
    while(t--){
        cin>>temp;
        totient = temp;
        vector <int> v;
        v.reserve(100);
        int i = 0;
        
        while (temp != 1){
            v.push_back(arr[temp]);
            totient /= arr[temp];
            temp /= arr[temp];
            while(v[i] == arr[temp]){
                temp /= arr[temp];
            }
            i++;
        }
        
        for(long i:v){
            totient *= (i-1);
        }
        cout<<totient<<endl;
    }
	return 0;
}
        cin>>a;
     
        int ans=a;
        for(auto it:v)
        {
            if(it>a)
                break;
            if(a%it==0)
            {
                ans*=(it-1);
                ans/=it;
                while(a%it==0)  a/=it;
            }
        }

        cout<<ans<<endl;

If v contains prime numbers, then you need to do this . Make sure you do not process for primes greater than the input n to avoid tle.

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

1 Like

plz tell me what’s wrong with it

Output :

TESTCASE # 1 : correct (Time: 0.12 s)
TESTCASE # 2 : wrong-answer (Time: 0.01 s)
TESTCASE # 3 : wrong-answer (Time: 0.01 s)
TESTCASE # 4 : correct (Time: 0.01 s)
TESTCASE # 5 : correct (Time: 0 s)