Cod sursa(job #953155)
| Utilizator | Data | 25 mai 2013 08:48:15 | |
|---|---|---|---|
| Problema | Sum | Scor | 85 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.5 kb |
#include <fstream>
#include <vector>
using namespace std;
ifstream f("sum.in");
ofstream g("sum.out");
const int mx=100001;
void fctrz();
int phi[mx]={0,1};
int main()
{
int t;
f>>t;
fctrz();
while(t--){
long long n;
f>>n;
g<<2LL*phi[n]*n<<'\n';
}
return 0;
}
void fctrz()
{
for(int i=2;i<mx;i++)
phi[i]=i-1;
for(int i=2;i<mx;i++){
for(int j=2;i*j<mx;j++)
phi[i*j]-=phi[i];
}
}
