洛谷P1014 Cantor表
P1014 Cantor表
题目描述
现代数学的著名证明之一是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,…
输入输出格式
输入格式:
整数N(1≤N≤10000000)
输出格式:
表中的第N项
输入输出样例
7
1/4
/*找规律啊*/
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int sum[],n;
int main(){
for(int i=;i<=;i++)sum[i]=sum[i-]+i;
scanf("%d",&n);
int pos=lower_bound(sum+,sum+,n)-sum;
int s=sum[pos-]+;int plus=pos+;//分子和分母之和为plus
int mu=n-s+;
int z=plus-mu;
if(pos%==)swap(z,mu);
printf("%d/%d",z,mu);
}
洛谷P1014 Cantor表的更多相关文章
- 洛谷——P1014 Cantor表
P1014 Cantor表 题目描述 现代数学的著名证明之一是Georg Cantor证明了有理数是可枚举的.他是用下面这一张表来证明这一命题的: 1/1 1/2 1/3 1/4 1/5 … 2/1 ...
- 洛谷 P1014 Cantor表
P1014 Cantor表 题目描述 现代数学的著名证明之一是Georg Cantor证明了有理数是可枚举的.他是用下面这一张表来证明这一命题的: 1/1 1/2 1/3 1/4 1/5 … 2/1 ...
- [NOIP1999] 提高组 洛谷P1014 Cantor表
题目描述 现代数学的著名证明之一是Georg Cantor证明了有理数是可枚举的.他是用下面这一张表来证明这一命题的: 1/1 1/2 1/3 1/4 1/5 … 2/1 2/2 2/3 2/4 … ...
- 洛谷 P1014 Cantor表 Label:续命模拟QAQ
题目描述 现代数学的著名证明之一是Georg Cantor证明了有理数是可枚举的.他是用下面这一张表来证明这一命题的: 1/1 1/2 1/3 1/4 1/5 … 2/1 2/2 2/3 2/4 … ...
- (模拟) codeVs1083 && 洛谷P1014 Cantor表
题目描述 Description 现代数学的著名证明之一是Georg Cantor证明了有理数是可枚举的.他是用下面这一张表来证明这一命题的: 1/1 1/2 1/3 1/4 1/5 … 2/1 2/ ...
- 洛谷 P1014 Cantor表【蛇皮矩阵/找规律/模拟】
题目描述 现代数学的著名证明之一是Georg Cantor证明了有理数是可枚举的.他是用下面这一张表来证明这一命题的: 1/1 1/2 1/3 1/4 1/5 … 2/1 2/2 2/3 2/4 … ...
- java实现 洛谷 P1014 Cantor表
题目描述 现代数学的著名证明之一是Georg Cantor证明了有理数是可枚举的.他是用下面这一张表来证明这一命题的: 1/1 1/2 1/3 1/4 1/5 - 2/1 2/2 2/3 2/4 - ...
- (水题)洛谷 - P1014 - Cantor表
https://www.luogu.org/problemnew/show/P1014 很显然同一对角线的和是相等的.我们求出前缀和然后二分. 最后注意奇偶的顺序是相反的. #include<b ...
- 洛谷P1482 Cantor表(升级版) 题解
题目传送门 此题zha一看非常简单. 再一看特别简单. 最后瞟一眼,还是很简单. 所以在此就唠一下GCD大法吧: int gcd(int x,int y){ if(x<y) return gcd ...
随机推荐
- (转)source insight 窗口嵌入
昨天用了一下source insight ,都说很强大,也有感觉,但是这个强大的东西往往不是那么容易弄清楚的,或者一下子就好上手的,工具强大,功能复杂多样,一开始不知道怎么入手,以后慢慢来吧,学习是要 ...
- (转)CentOS 5.5 64bit 编译安装Adobe FlashMediaServer 3.5
http://download.macromedia.com/pub/flashmediaserver/updates/4_0_2/Linux_32bit/FlashMediaServer4.tar. ...
- Android/iOS Remote debugging
简单介绍 使用下面方法可以定位webview中的元素,无法定位view中的元素. 原文地址:http://mp.weixin.qq.com/s/y_UfdgjT_pkKgYivJmqt7Q webvi ...
- pinpoint本地开发-web模块
web模块中的前端依赖会导致工程很难打包成功,对于这些,我们可以直接注释掉 比如: <plugin> <groupId>com.github.eirslett</grou ...
- android程序的真正入口
代码出自MtAndroid 3.1.2完全开发手册,适用于Android平台. 概述 android程序的真正入口是Application类的onCreate方法.它的继承关系如下所示: java.l ...
- darknet YOLOv2安装及数据集训练
一. YOLOv2安装使用 1. darknet YOLOv2安装 git clone https://github.com/pjreddie/darknetcd darknetmake或到网址上下载 ...
- codevs 1531山峰
传送门 1531 山峰 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 钻石 Diamond 题目描述 Description Rocky山脉有n个山峰,一字排开,从西向东 ...
- EntityFramework Code First 构建外键关系,数据库不生成外键约束
创建 ExtendedSqlGenerator类 public class ExtendedSqlGenerator : SqlServerMigrationSqlGenerator { #regio ...
- 用linqpad来插入多条数据
其中Customers为数据库的某个表名, Custom自动被默认为单条记录的对象, 利用构造,InsertOnSubmit, 以及SubmitChanges实现插入数据. 注意:linqpad的la ...
- Poco 编译mysql
POCO mysql需要自己添加connecter的header和lib MySQL Client: For the MySQL connector, the MySQL client librari ...