Codeforces Round #382 (Div. 2) C
来源:互联网 发布:大数据掌握的技术 编辑:程序博客网 时间:2024/05/18 13:47
题意 有n个人进行两两对抗的比赛,问冠军最后最多可以打几场要求对战的人胜场差距不能大于1.
我们可以得到战一场至少需要2个人,战两场至少需要3个人。
那么如果需要战三场,就需要一个战胜了两场的和一个战胜了一场的就需要5个人
所以得到了递推式
a[i]=a[i-1]+a[i-2];
斐波那契;直接上代码ac
#include<stdio.h>#include<string.h>int main(){ long long a[150]; a[1]=2;a[2]=3; for(int i=3;i<=86;i++) a[i]=a[i-1]+a[i-2]; long long b; scanf("%lld",&b); for(int i=1;i<=86;i++) if(a[i]>b) { printf("%d\n",i-1); break; }}
0 0
- Codeforces Round #382 (Div. 2) C
- Codeforces Round #382 (Div. 2)C
- 【codeforces】Codeforces Round #370 (Div. 2) C
- Codeforces Round #382 (Div. 2)
- Codeforces Round #382 (Div. 2)
- Codeforces Round #382 (Div. 2)
- Codeforces Round #382 (Div. 2)
- Codeforces Round #382 (Div. 2) C - Tennis Championship
- Codeforces Round #382 (Div. 2)C. Tennis Championship(贪心)
- Codeforces Round #382 (Div. 2)-C. Tennis Championship
- Codeforces Round #105 (Div. 2) C
- Codeforces Round 134 div 2 C题
- Codeforces Round #137 (Div. 2), problem: (C)
- Codeforces Round #153 (Div. 2) C题
- Codeforces Round #158 (Div. 2) C题
- Codeforces Round #162 (Div. 2) C
- Codeforces Round #166 (Div. 2) c. Secret
- Codeforces Round#170(Div 2)C
- iOS中NSString自适应宽高
- 八种排序算法
- Windows下使用DOS命令进入MySQL数据库
- C#将文件转成16进制码流写入数据库存起来,访问的时候再还原成PDF文件
- he method setAttribute(String,object)in the type HttpSession is not appl
- Codeforces Round #382 (Div. 2) C
- EF框架(一)搭建过程
- Unity3d与Android交互总结
- java中length,length(),size()区别
- android Studio中preview 的显示、固定与隐藏
- 802.1P和IP Precedence及DSCP优先级的分类和对应
- 实现字符串右循环移位函数
- Swift-存储属性
- 字符串直接转NSNumber时崩溃