Georg Cantor用这张数表证明了有理数是可枚举的
刘汝佳教主的白书上有这道题,不过貌似解答是错误的T_T
1/1 1/2 1/3 1/4 1/5 …
2/1 2/2 2/3 2/4 …
3/1 3/2 3/3 …
4/1 4/2 …
5/1 …
#include<stdio.h> #include<math.h> int main() { //freopen("data.in", "r", stdin); int n, k, i, sum; while (~scanf("%d", &n)) { k =(int) floor((sqrt(1.0 + n * 8.0)-1)/2-1e-9)+1; sum = k * (k + 1) / 2; i = sum - n + 1; if(k&1) { printf("TERM %d IS %d/%d\n",n, i, k - i + 1); } else { printf("TERM %d IS %d/%d\n",n, k-i+1,i); } } return 0; }