Cod sursa(job #1213500)
Utilizator | Data | 28 iulie 2014 12:35:55 | |
---|---|---|---|
Problema | Fractii | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.41 kb |
#include<iostream>
#include<fstream>
using namespace std;
ifstream in("fractii.in");
ofstream out("fractii.out");
int prime(int p, int q){
if(p<q)
swap(p,q);
if(p%q==0)
return 0;
int i;
for(i=2;i<=q;i++)
if(p%i==0 && q%i==0)
return 0;
return 1;
}
int main(){
int n,p,q,s=0;
in>>n;
s=n*n;
for(p=2;p<=n;p++)
for(q=2;q<=n;q++)
if(!prime(p,q))
s--;
out<<s<<"\n";
return 0;
}