codeforces #382 div2 C. Tennis Championship(打表找规律)
题意:n个人进行淘汰赛制的比赛,输的人直接被淘汰,不进行下一轮,现在要求两个人可以比赛当且仅当两个人的胜场数相差小于等于1,现在问赢得最多场的那个人,最多可能赢多少场。
思路:打表找规律。。。麻蛋。。手算错了n=8。。。结果达成了f[1] = 2,fib[2] =4 的奇怪的fib数列。。。卡了一个多小时。。。气哭了。。。
1/* ***********************************************
2Author :111qqz
3Created Time :2016年11月29日 星期二 10时16分50秒
4File Name :code/cf/#382/C.cpp
5************************************************ */
6
7#include <cstdio>
8#include <cstring>
9#include <iostream>
10#include <algorithm>
11#include <vector>
12#include <queue>
13#include <set>
14#include <map>
15#include <string>
16#include <cmath>
17#include <cstdlib>
18#include <ctime>
19#define fst first
20#define sec second
21#define lson l,m,rt<<1
22#define rson m+1,r,rt<<1|1
23#define ms(a,x) memset(a,x,sizeof(a))
24typedef long long LL;
25#define pi pair < int ,int >
26#define MP make_pair
27
28using namespace std;
29const double eps = 1E-8;
30const int dx4[4]={1,0,0,-1};
31const int dy4[4]={0,-1,1,0};
32const int inf = 0x3f3f3f3f;
33unsigned long long n;
34unsigned long long x,y,z;
35unsigned long long solve( unsigned long long xx)
36{
37 if (xx<=2) return 1;
38 if (xx<=4) return 2;
39 x = 1;
40 y = 2;
41 int p;
42 unsigned long long cur = 4;
43 for ( int i = 3 ; ; i++)
44 {
45 z = x + y;
46 x = y;
47 y = z;
48 cur = cur + z;
49 if (cur>=xx)
50 {
51 p = i;
52 break;
53 }
54 }
55 //cout<<p<<endl;
56 return p;
57
58}
59int main()
60{
61 #ifndef ONLINE_JUDGE
62// freopen("code/in.txt","r",stdin);
63 #endif
64 cin>>n;
65 unsigned long long ans = solve(n);
66 cout<<ans<<endl;
67
68
69 #ifndef ONLINE_JUDGE
70 fclose(stdin);
71 #endif
72 return 0;
73}