Cantor表

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
 
long long n;
 
int erfen()
{
	int left=1,right=1500;
	int mid;
	while(left+1<right)
	{
		mid=left+(right-left)/2;
		long long ans=(mid*mid-mid)/2+1;
		if(ans>n)
			right=mid;
		else if(ans==n)return mid;
		else 
			left=mid;
	}
	return left;
}
int main()
{
	scanf("%d",&n);
	int num=erfen();
	if(!(num%2))
	{
		int k=n-(num*num-num)/2;
		printf("%d/%d",k,num+1-k);
	}
	else
	{
		int k=n-((num*num-num))/2;
		printf("%d/%d",num+1-k,k);
	}
	return 0;
}
posted @ 2019-08-04 16:50  Zforw  阅读(44)  评论(0)    收藏  举报