Cod sursa(job #307721)

Utilizator mathboyDragos-Alin Rotaru mathboy Data 24 aprilie 2009 20:43:30
Problema Sum Scor 35
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.06 kb
#include <stdio.h>
#define max 200000
long long n,c,x,i,j,ciur[max],a,b,k,s=0;
int main()
{ freopen("sum.in","r",stdin);
  freopen("sum.out","w",stdout);
    scanf("%lld",&n);
    for(i=1;i<=n;i++)
       { 
                     scanf("%lld",&x);
             for(j=1;j<=2*x;++j) ciur[j]=1;      
             for(j=1;j<=2*x; ++j)
                { 
                    if(ciur[j])
                     { a=j;b=x;
                       while(b)
                        {
                               c=a%b;
                               a=b;
                               b=c;
                        }
                       if(a!=1)
                         {
                             for(k=j;k<=2*x;k+=k)
                              ciur[j]=0;
                         }
                     }
                }                       
            for(j=1;j<=2*x; ++j) if(ciur[j]) s+=j;
            printf("%lld\n",s);
            s=0;
       }
       return 0;
       }