Cod sursa(job #181226)

Utilizator firewizardLucian Dobre firewizard Data 18 aprilie 2008 02:08:44
Problema Sum Scor 50
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.51 kb
#include <stdio.h>
#include <math.h>
#define INF 100000
char v[100000];
unsigned long n,x,i,j,nr,c,sq/*,p[10000]*/;
unsigned long long s,ttnt;
int p[]={0,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,
101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,
199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,
317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,
443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,
577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,
701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,
839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,
983,991,997,1001,1003,1005,1007,1009,1011,1013,1015,1017,1019,1021,1023,1025,1027,
1029,1031,1033,1035,1037,1039};
int main()
{
    freopen("sum.in","r",stdin);
    freopen("sum.out","w",stdout);
    /*c=1;
    p[1]=2;
    for(i=3;i<=INF;i=i+2)      
    if(!v[i]) {p[++c]=i;
    for(j=3*i;j<=INF;j=j+2*i)v[j]=1;}*/
    scanf("%ld\n",&n);
    for(;n;n--)
    {
        scanf("%ld",&x);
        j=1;
        ttnt=x;nr=x; 
        while (nr>1){       
              if (nr%p[j]==0){
                 while(nr%p[j]==0)nr/=p[j];
                 ttnt=ttnt*(p[j]-1)/p[j];
                 }
              j++;
              }
        s=2*ttnt*x;
        printf("%lld\n",s);
        ttnt=0;s=0;
    }
    return 0;
}