problemcutter

导航

SPOJ Problem 302:Count on Cantor

题目不复述了,自己看吧。http://www.spoj.com/problems/CANTON/一如既往的暴力。。

#include<cstdio>
int n,i,j,s,ans;
int main(){
    scanf("%d",&n);
    while(n--){
        scanf("%d",&s);
        printf("TERM %d IS ",s);
        for (i=1;s>i;i++){
            s-=i;
        }
        if (i&1)
            printf("%d/%d\n",i-s+1,s);else
            printf("%d/%d\n",s,i-s+1);
    }
}

 

posted on 2015-03-05 20:43  problemcutter  阅读(94)  评论(0编辑  收藏  举报