Cod sursa(job #974886)

Utilizator bgdiBogdan Angheluta bgdi Data 18 iulie 2013 17:38:35
Problema Sum Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.58 kb
// Sum.cpp : Defines the entry point for the console application.
//

//#include "stdafx.h"
#include <iostream>
#include <fstream>
using namespace std;

ifstream fin ("sum.in");
ofstream fout ("sum.out");

int n, x, i, j, div_max=0, a, b, rest, found;
long int sum;

int main()
{
	fin>>n;
	for (i=1; i<=n; i++) {
		sum=0;
		fin>>x;
		for (j=1; j<2*x; j++) {
			a=2; found=1;
			while (found==1) {
				if (j%a==0 && x%a==0)
					found=0;
				else if (a!=x)
					a++;
				else {
					sum=sum+j;
					found=0;
				}
			}
		}
		fout<<sum<<"\n";
	}
	return 0;
}