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