Cod sursa(job #193022)
Utilizator | Data | 1 iunie 2008 21:47:56 | |
---|---|---|---|
Problema | Frac | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.27 kb |
#include<fstream.h>
#include<iostream.h>
int main()
{
int n,p,i,x,y,j=0;
ifstream a("frac.in");
ofstream b("frac.out");
a>>n>>p;
for(i=1; i<=n*p; i++)
{
j++;
x=n; y=i;
while(x!=y) if(x>y) x-=y; else y-=x;
if((x==1)&&(j==p)) b<<i;
}
return 0;
}