Cod sursa(job #1249515)
| Utilizator | Data | 27 octombrie 2014 08:20:51 | |
|---|---|---|---|
| Problema | Sum | Scor | 50 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.59 kb |
#include <stdio.h>
#include <stdlib.h>
char v[1000111];
int n, x, i, y, j;
long long int s;
int main()
{
freopen("sum.in", "r", stdin);
freopen("sum.out", "w", stdout);
scanf("%d", &n);
for(i = 0; i < n; i++)
{
s = 1;
scanf("%d", &x);
for(y = 2; y <= 2*x; y++)
v[y] = 1;
for(y = 2; y <= 2*x; y++)
if(x % y == 0)
v[y] = 0;
for(y = 2; y <= 2*x; y++)
{
if(v[y] == 0)
{
for(j = y+y; j <= 2*x; j += y)
v[j] = 0;
}
}
for(y = 2; y <= 2*x; y++)
if(v[y])
{
s += y;
}
printf("%lld\n", s);
}
return 0;
}