Cod sursa(job #975044)

Utilizator bgdiBogdan Angheluta bgdi Data 18 iulie 2013 21:57:12
Problema Sum Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.8 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, test;
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; test=1;
			while (a!=x) {                 //while (found==1) {
				if (j%a==0 && x%a==0) {    //if (j%a==0 && x%a==0)
					test=0; a=x;           //found=0;
				}
				else                       //else if (a!=0)
				a=a+1;                     //a++;
			}                              //else {
			if (test==1)                    //sum=sum+j; found=0; }
				sum=sum+j;				   //}
		}
		fout<<sum<<"\n";
	}
	return 0;
}