Cod sursa(job #2075512)
| Utilizator | Data | 25 noiembrie 2017 14:58:47 | |
|---|---|---|---|
| Problema | Sum | Scor | 50 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.77 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("sum.in");
ofstream fout("sum.out");
int main()
{
int n, x;
fin >> n;
for(int i=1;i<=n;i++)
{
fin >> x;
int multipli[200010]{0}, div[100]{0}, k=0, j;
unsigned long long sum=0;
for(j=2;j*j<x;j++)
if(x%j==0)
{
div[++k]=j;
div[++k]=x/j;
}
if(j*j==x)
div[++k]=j;
div[++k]=x;
for(int l=1;l<=k;l++)
for(int h=div[l];h<=2*x;h+=div[l])
multipli[h]=1;
for(int h=1;h<=2*x;h++)
if(!multipli[h])
sum+=h;
fout << sum << "\n";
}
return 0;
}
