• codevs1083 Cantor表


    题目描述 Description

    现代数学的著名证明之一是Georg Cantor证明了有理数是可枚举的。他是用下面这一张表来证明这一命题的: 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 … … 我们以Z字形给上表的每一项编号。第一项是1/1,然后是1/2,2/1,3/1,2/2,…

    输入描述 Input Description

    整数N(1≤N≤10000000)

    输出描述 Output Description

    表中的第N项

    样例输入 Sample Input

    7

    样例输出 Sample Output

    1/4

    int main(){
    	int n,i,j,s,x=0;
    	scanf("%d",&n);
    	for(i=0;x*(x+1)/2<n;i++)x++;
    	s=n-x*(x-1)/2;
    	if(x%2!=0)printf("%d/%d
    ",x+1-s,s);
    	else printf("%d/%d
    ",s,x+1-s);
    	return 0;
    }

  • 相关阅读:
    butter
    医院设置
    NOIP 2000 进制转换
    图的M 着色问题
    闭合区域面积统计
    字符序列
    装载问题
    n皇后问题
    跳马问题
    数独
  • 原文地址:https://www.cnblogs.com/codetogether/p/7066237.html
Copyright © 2020-2023  润新知