Cod sursa(job #2239705)

Utilizator Moise_AndreiMoise Andrei Moise_Andrei Data 11 septembrie 2018 18:10:41
Problema Sum Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.61 kb
#include <bits/stdc++.h>
using namespace std;
ifstream in("sum.in");
ofstream out("sum.out");
bool c[200005];
int  v[200005];
void f()
{
    for(int i = 2; i <= 200000; i ++)
    {
        if(c[i] == 0)
        {
            v[i] = i;
            for(int j = i + i; j <= 200000; j += i)
            {
                c[i] = 1;
            }
        }
    }
}
int main()
{
    f();
    for(int i = 1; i <= 200000; i ++)
        v[i] += v[i - 1];
    int n;
    cin >> n;
    for(int i = 1; i <= n; i ++)
    {
        int x;
        cin >> x;
        cout << v[x * 2];
    }
    return 0;
}