洛谷1014 Cantor表

 
水题。随便搞搞就过了。
//Serene
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
using namespace std;
const int maxn=1e7+10;
int n,tot,x,y;

int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;++i) {
		tot+=i;
		if(tot>=n) {
			tot-=i; x=i; y=(i&1)? i-(n-tot)+1:n-tot; x=x-y+1;
			printf("%d/%d",y,x); break;
		}
	}
	return 0;
}

  

posted @ 2017-10-05 10:23  shixinyi  阅读(192)  评论(0编辑  收藏  举报