标签:des style http color strong io for cti
Description
1/1 1/2 1/3 1/4 1/5 ...
2/1 2/2 2/3 2/4
3/1 3/2 3/3
4/1 4/2
5/1
Input
Output
Sample Input
3 14 7
Sample Output
TERM 3 IS 2/1 TERM 14 IS 2/4 TERM 7 IS 1/4
代码:
#include <stdio.h>
#include <string.h>
int main()
{
int n;
int i, j;
int dd, ff;
int d, c;
while(scanf("%d", &n)!=EOF )
{
d = 1;
while(( (1+d)*d)/2 < n)
{
d++;
}
c = d-1;
if(d%2==1)//奇数列
{
dd = d-( n-(1+c)*c/2 )+1 ;
ff = n-(1+c)*c/2;
}
else if(d%2==0)//偶数列
{
dd = n-(1+c)*c/2 ;
ff = d-( n-(1+c)*c/2 ) +1;
}
printf("TERM %d IS %d/%d\n", n, dd, ff );
}
return 0;
}
标签:des style http color strong io for cti
原文地址:http://www.cnblogs.com/yspworld/p/3874836.html