(水题)洛谷 - P1014 - Cantor表
https://www.luogu.org/problemnew/show/P1014
很显然同一对角线的和是相等的。我们求出前缀和然后二分。
最后注意奇偶的顺序是相反的。
#include<bits/stdc++.h>
using namespace std;
#define ll long long int prefix[]; int init(){
prefix[]=;
for(int i=;i<=;i++){
prefix[i]=prefix[i-]+i;
}
//cout<<prefix[65535]<<endl;
} int main(){
init();
int n;
scanf("%d",&n);
int id=lower_bound(prefix,prefix+,n)-prefix;
id--;
int res=n-prefix[id];
int sum=id+;
if(sum%==)
res=sum-res;
printf("%d/%d\n",res,sum-res); }
(水题)洛谷 - 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 ...
- 洛谷 P1014 Cantor表
P1014 Cantor表 题目描述 现代数学的著名证明之一是Georg Cantor证明了有理数是可枚举的.他是用下面这一张表来证明这一命题的: 1/1 1/2 1/3 1/4 1/5 … 2/1 ...
- 洛谷 P1014 Cantor表 Label:续命模拟QAQ
题目描述 现代数学的著名证明之一是Georg Cantor证明了有理数是可枚举的.他是用下面这一张表来证明这一命题的: 1/1 1/2 1/3 1/4 1/5 … 2/1 2/2 2/3 2/4 … ...
- [NOIP1999] 提高组 洛谷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 - ...
- (模拟) 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 … ...
- 洛谷1014 Cantor表
水题.随便搞搞就过了. //Serene #include<algorithm> #include<iostream> #include<cstring> #i ...
随机推荐
- vue 实现 扫二维码 功能
前段时间一直在研究,如何通过 vue 调用 相机 实现 扫一扫的功能,但是查看文档发现,需要获取 getUserMedia 的属性值,但存在兼容性问题. 退而求其次,通过 h5plus 来实现. 1. ...
- JAVA设计模式之单例模式(转)
本文继续介绍23种设计模式系列之单例模式. 概念: java中单例模式是一种常见的设计模式,单例模式的写法有好几种,这里主要介绍三种:懒汉式单例.饿汉式单例.登记式单例. 单例模式有以下特点: 1.单 ...
- java开始到熟悉72-76
本次内容:异常机制 1.为什么需要异常 2.异常 3.error类 4.exception类 5.exception类中的unchecked exception 举例: 6.常用异常处理方法 a.tr ...
- ubuntu 的权限和目录
/ : 根目录 /bin 和 /sbin中放置的是可执行文件 /etc 里面放的是配置文件 /boot 引导 /mnt 是挂载目录 /home 主目录 /dev 设备 /usr li ...
- 【Leetcode】经典的Jump Game in JAVA
Given an array of non-negative integers, you are initially positioned at the first index of the arra ...
- HDU 1284 钱币兑换问题 (完全背包)
钱币兑换问题 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Subm ...
- Hibernate - DetachedCriteria 的完整用法(转)
现在对 Hibernate的Criteria 的用法进行总结: Hibernate 设计了 CriteriaSpecification 作为 Criteria 的父接口,下面提供了 Crite ...
- CustomView
https://github.com/eltld/CustomView
- 软件版本号(BETA、RC、ALPHA、Release、GA等)
Alpha: Alpha是内部测试版,一般不向外部发布,会有很多Bug.除非你也是测试人员,否则不建议使用.是希腊字母的第一位,表示最初级的版本,alpha 就是α,beta 就是β , ...
- MYSQL使用inner join 进行 查询/删除/修改示例
代码如下: --查询 SELECT tp.tp_id, tp.tpmc, tp.leveid, tp.tpdz, tp.jgm, tp.scsj, tp.pbzyid, tp.ksbfsj, tp.j ...