Codeforces 735C:Tennis Championship(数学+贪心)
http://codeforces.com/problemset/problem/735/C
题意:有n个人打锦标赛,淘汰赛制度,即一个人和另一个人打,输的一方出局。问这n个人里面冠军最多能赢多少场,其中一个人和另一个人能打比赛当且仅当这两个人赢的局数相差不超过1。
思路:比赛的时候不会做..直接log2(n)交,果断错了。看题解:因为限制条件两个人能比赛当且仅当他们赢得局数相差不超过1,设F[x]为冠军赢x盘的时候需要的总人数,那么有这样的递推式:F[x] = F[x-1] + F[x-2].(其中x-1的人和x-2的人打一盘,赢的人是x-1,就可以变成x了)。就是斐波那契数列。初始的时候F[1] = 2, F[2] = 3。因为斐波那契递增的很快,在1e18里面数量不多,所以先打出一个表,然后二分查找 n >= F[x] 的x,就是最后的答案了。
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <iostream>
using namespace std;
const int N = ; long long dp[N]; int main() {
long long n;
cin >> n;
dp[] = ; dp[] = ;
int r = ;
for( ; ; r++) {
dp[r] = dp[r-] + dp[r-];
if(dp[r] > 1e18) break;
}
int l = ;
while(l <= r) {
int mid = (l + r) >> ;
if(dp[mid] <= n) l = mid + ;
else r = mid - ;
}
printf("%d\n", r);
return ;
}
Codeforces 735C:Tennis Championship(数学+贪心)的更多相关文章
- codeforces 735C. Tennis Championship(贪心)
题目链接 http://codeforces.com/contest/735/problem/C 题意:给你一个数n表示有几个人比赛问最多能赢几局,要求两个比赛的人得分不能相差超过1即得分为2的只能和 ...
- codeforces 735C Tennis Championship(贪心+递推)
Tennis Championship 题目链接:http://codeforces.com/problemset/problem/735/C ——每天在线,欢迎留言谈论. 题目大意: 给你一个 n ...
- Educational Codeforces Round 20 C 数学/贪心/构造
C. Maximal GCD time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- Codeforces Round #382 (Div. 2)C. Tennis Championship 动态规划
C. Tennis Championship 题目链接 http://codeforces.com/contest/735/problem/C 题面 Famous Brazil city Rio de ...
- Codeforces Round #382 (Div. 2) C. Tennis Championship 斐波那契
C. Tennis Championship time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- Codeforces Round #382 (Div. 2) C. Tennis Championship
C. Tennis Championship time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- C. Tennis Championship dp递推 || 找规律
http://codeforces.com/contest/735/problem/C C. Tennis Championship time limit per test 2 seconds mem ...
- Tennis Championship
Tennis Championship time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces735C Tennis Championship 2016-12-13 12:06 77人阅读 评论(0) 收藏
C. Tennis Championship time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- codeforces Gym 100338E Numbers (贪心,实现)
题目:http://codeforces.com/gym/100338/attachments 贪心,每次枚举10的i次幂,除k后取余数r在用k-r补在10的幂上作为候选答案. #include< ...
随机推荐
- JSON Web Token
What is JSON Web Token? JSON Web Token (JWT) is an open standard (RFC 7519) that defines a compact a ...
- 在Hyper-V的虚拟机中使用无线网络
今天在WINDOWS 8.1中装了WINDOWS 7的虚拟机,但默认情况下只能共享有线网络,而没有无线网络. 解决方法: http://www.elmajdal.net/Win2k8/Enabling ...
- 12C对ASM rebalance操作的优化
如果在执行"alter diskgroup"操作.或在添加.删除磁盘而引发的隐式rebalance的时,没有指定power选项,rebalance操作会使用初始化参数asm_pow ...
- intellij idea exclude from compile后怎么加回来
File->Settings-> Build,Execution,Deployment->Compiler-> Execludes
- 新版mysql(mysql-5.7.12-winx64)安装
之前安装了一个php集成运行环境的mysql,不太习惯,还是想弄一个原生的环境来进行学习.于是,卸载了php集成环境中的mysql. 计算机环境:win7 x64. 1.mysql-5.7.12-wi ...
- 提高神经网络的学习方式Improving the way neural networks learn
When a golf player is first learning to play golf, they usually spend most of their time developing ...
- redhat linux 安装mysql5.6.27
1.yum安装mysql(root身份) yum install mysql-server mysql-devel mysql -y 如没有配置yum,请参见博客:http://www.cnblogs ...
- AJAX简单的数据增删改与分页应用
运行截图: PageBar.js: /* * 说明: * 整体思想,1.第一页时不显示:首页,上一页, * 2.最后一页时不显示:下一页,尾页 * 3.中间有 5 页导航, * 若:3.1.(总页数& ...
- 大数据Spark超经典视频链接全集
论坛贴吧等信息发布参考模板 Scala.Spark史上最全面.最详细.最彻底的一整套视频全集(特别是机器学习.Spark Core解密.Spark性能优化.Spark面试宝典.Spark项目案例等). ...
- poj: 1003
简单题 #include <iostream> #include <stdio.h> #include <string.h> #include <stack& ...