Cod sursa(job #697504)
Utilizator | Data | 29 februarie 2012 09:31:48 | |
---|---|---|---|
Problema | Frac | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.37 kb |
#include<iostream>
#include<fstream>
using namespace std;
int prim(int a,int b)
{while(a!=b)
if(a>b)
a=a-b;
else b=b-a;
return a;}
int main()
{ifstream f("frac.in");
ofstream g("frac.out");
int i,j;
long long n,p;
f>>n;
f>>p;
i=1;
j=0;
while(j<p)
{if(prim(i,n)==1)
{j++;
cout<<i<<"/"<<n<<" ";}
i++;
}
g<<i-1;
f.close();
g.close();
}