赞
踩
算法篇——Cantor的数表 - SteveWang - 博客园 (cnblogs.com)
- #include <bits/stdc++.h>
- using namespace std;
- int high(int n)
- {
- return n*(n+1)/2;
- }
- int main()
- {
- int k;
- cin>>k;
- int n=1;
- while(1)
- {
- if(high(n)>=k)
- {
- break;
- }
- n++;
- }
- int m=high(n);
- int w=m-k+1;
- if(n%2==0)
- {
- cout<<n-w+1<<"/"<<w;
- }
- else{ cout<<w<<"/"<<n-w+1;}
-
- return 0;
- }
![](https://csdnimg.cn/release/blogv2/dist/pc/img/newCodeMoreWhite.png)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。