题目描述 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

数据范围及提示 Data Size & Hint

见描述

思路 模拟+统计

 #include<cmath>
 #include<cstdio>
 #include<string>
 #include<cstring>
 #include<iostream>
 #include<algorithm>
 using namespace std;
 int re(int a,int b)
 {
     cout<<a<<'/'<<b<<endl;
     ;
 }
 int main()
 {
     int n;
     cin>>n;
     ,i=,j=;
     ,J=;
     <)
     {
         )
         {
             if(I)
             {
                 if(x==n)
                 {
                     re(i,j);
                     ;
                 }
                 j++;
                 x++;
             }
             )
                 {
                     if(x==n)
                     {
                         re(i,j);
                         ;
                     }
                     i++;
                     j--;
                     x++;
                 }
             I=!I;
         }
         &&i!=)
         {
             if(J)
             {
                 if(x==n)
                 {
                     re(i,j);
                     ;
                 }
                 i++;
                 x++;
             }
             )
                 {
                     if(x==n)
                     {
                         re(i,j);
                         ;
                     }
                     i--;
                     j++;
                     x++;
                 }
             J=!J;
         }
     }
     cout<<i<<'/'<<j<<endl;
     ;
 }

Cantor表 1083的更多相关文章

  1. 【CodeVS】1083 Cantor表

    1083 Cantor表 1999年NOIP全国联赛普及组 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 白银 Silver 题目描述 Description 现代数学的著名证明之 ...

  2. wikioi 1083 Cantor表

    题目描述 Description 现代数学的著名证明之一是Georg Cantor证明了有理数是可枚举的.他是用下面这一张表来证明这一命题的: 1/1 1/2 1/3 1/4 1/5 - 2/1 2/ ...

  3. NOIP199904求Cantor表

    求Cantor表 题目描述 Description 现代数学的著名证明之一是Georg Cantor证明了有理数是可枚举的.他是用下面这一张表来证明这一命题的: 1/1 1/2 1/3 1/4 1/5 ...

  4. Cantor表(NOIP1999)

    题目链接:Cantor表 这道题很水,但有的人没看懂题意,这不怪大家,怪题目没说清楚. 给张图: 看到这,你应该明白题目意思了. 先看看有什么规律. 我把这个数列写出来: 1/1,1/2,2/1,3/ ...

  5. 14. Cantor表

    时间限制: 1 s 空间限制: 128000 KB 题目等级 : 白银 Silver 题解 查看运行结果 题目描述 Description 现代数学的著名证明之一是Georg Cantor证明了有理数 ...

  6. 洛谷——P1014 Cantor表

    P1014 Cantor表 题目描述 现代数学的著名证明之一是Georg Cantor证明了有理数是可枚举的.他是用下面这一张表来证明这一命题的: 1/1 1/2 1/3 1/4 1/5 … 2/1 ...

  7. 洛谷P1014 Cantor表

    P1014 Cantor表 题目描述 现代数学的著名证明之一是Georg Cantor证明了有理数是可枚举的.他是用下面这一张表来证明这一命题的: 1/1 1/2 1/3 1/4 1/5 … 2/1 ...

  8. 洛谷 P1014 Cantor表

    P1014 Cantor表 题目描述 现代数学的著名证明之一是Georg Cantor证明了有理数是可枚举的.他是用下面这一张表来证明这一命题的: 1/1 1/2 1/3 1/4 1/5 … 2/1 ...

  9. C语言程序设计100例之(3): Cantor表

    例3    Cantor表 题目描述 现代数学的著名证明之一是Georg Cantor证明了有理数是可枚举的.他是用下面这一张表来证明这一命题的: 1/1  1/2  1/3  1/4  …… 2/1 ...

随机推荐

  1. hh monitor

    http://theholyjava.wordpress.com/2012/09/21/enabling-jmx-monitoring-for-hadoop-and-hive/ http://blog ...

  2. 【一题多解】 map 二分 hash trie poj 2503

    各种方式解这道题!! 利用map 超时了 #include <iostream> #include <string> #include <map> using na ...

  3. 【A + B + C + D】 问题

    A + B + C + D Time Limit: 40000/20000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...

  4. Servlet Filter 过滤器

    Filter也称之为过滤器,它是Servlet技术中最激动人心的技术,WEB开发人员通过Filter技术,对web服务器管理的所有web资源: 例如Jsp, Servlet, 静态图片文件或静态 ht ...

  5. Struts2值栈详解

    1. 关于值栈: 1). helloWorld 时, ${productName} 读取 productName 值, 实际上该属性并不在 request 等域对象中, 而是从值栈中获取的.  2). ...

  6. encodeURIComponent与URLDecoder.decode用法

    在输入地址栏时有时一些信息需要在地址栏看不见,我们就需要对其信息在前台转码后台解码 js:encodeURIComponent编码与解码 今天在js往jsp和servlet传参的时候出现:JavaSc ...

  7. android Actionmode 样式自定义

    <style name="Base.Theme.DesignDemo" parent="Theme.AppCompat.Light.NoActionBar" ...

  8. c语言scanf详解

    函数名: scanf 功 能: 执行格式化输入 用 法: int scanf(char *format[,argument,...]);scanf()函数是通用终端格式化输入函数,它从标准输入设备(键 ...

  9. JSON 串 自定义解析字段

    我们有时候会只需要j一个很长的json串中的少数的key value ,这个时候我们不会特意去建立一个object 来映射属性,这个时候我们可以应用 gson的JsonParser  来解析json串 ...

  10. 命令行编译swc

    compc -source-path . -include-classes com.boyaa.landlo rd.module.room.RoomMain -output a.swc -compil ...