洛谷1014 Cantor表

时间:2017-10-05 11:55:22   收藏:0   阅读:233
 
水题。随便搞搞就过了。
//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;
}

  

原文:http://www.cnblogs.com/Serene-shixinyi/p/7628792.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!