-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path264.cpp
52 lines (50 loc) · 1.05 KB
/
264.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include<stdio.h>
int main()
{
long long int p,q,n;
while(scanf("%lld",&n)!=EOF)
{
p=1;
q=1;
printf("TERM %lld IS ",n);
while(1)
{
if(p==1)
{
n--;
if(n==0)
break;
q++;
n--;
while((q!=1)&&(n!=0))
{
p++;
q--;
if(q!=1)
n--;
}
}
else if(q==1)
{
n--;
if(n==0)
break;
p++;
n--;
if(n==0)
break;
while((p!=1)&&(n!=0))
{
p--;
q++;
if(p!=1)
n--;
}
}
if(n==0)
break;
}
printf("%lld/%lld\n",p,q);
}
return 0;
}