poj 1969(容易失误,注意顺序,但是不难,是水题)

#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    int n;
    while(scanf("%d",&n)==1){
        int k = 1;
        while(k*(k+1)/2<n)k++;
        k--;
        int t = n-k*(k+1)/2;
        k++;
        if(k%2==0)    printf("TERM %d IS %d/%d\n",n,t,k+1-t);
        else        printf("TERM %d IS %d/%d\n",n,k+1-t,t);
        //cout<<t<<"/"<<k+1-t<<endl;
    }
    return 0;
}

 

上一篇:poj 2027(水题)


下一篇:poj 1657(模拟,注意象的判定)