I try to use the Euler’s Totient Function for this problem and use printf and scanf instead of cin and cout too, but I still got Time Limit Exceeded. Can you guys help me with this? Thanks in advance. Here is my code.
//#include <iostream>
#include <cstdio>
//using namespace std;
int main() {
// your code goes here
unsigned int t; scanf("%d",&t); /*cin >> t;*/
while(t--) {
unsigned int n; scanf("%d",&n); /*cin >> n;*/ unsigned int p = 2; unsigned long long s = 0;
if (n==1) {printf("1\n"); /*cout << 1 << endl;*/ continue;}
while(n > 1) {
unsigned long long k = p-1;
while(n % p == 0) {n /= p; k *= p;}
k /= p; s += k; p++;
}
printf("%ld\n",s); /*cin >> s << endl;*/
}
return 0;
}