【NOIP1999】【codevs1083】Cantor表

problem

solution

codes

#include<iostream>
using namespace std;
int main(){
    int n, k=1;  cin>>n;
    //1.第n个数在第k条斜线上(前k条斜线的数的个数为等差数列)
    while((1+k)*k/2 < n)k++;
    int s = n-(1+k-1)*(k-1)/2;
    //2.偶数从上往下
    if(k%2==0)cout<<s<<"/"<<k+1-s<<"\n";
    else cout<<k+1-s<<"/"<<s<<"\n";
    return 0;
}
posted @ 2018-06-01 21:20  gwj1139177410  阅读(198)  评论(0)    收藏  举报
选择