题目描述
N个石子,A和B轮流取,A先。每个人每次最少取一个,最多不超过上一个人的个数的2倍。
取到最后一个石子的人胜出,如果A要有必胜策略,第一次他至少要取多少个。
输入
第一行给出数字N,N<=10^15.第二行N个数字
输出
如题
样例输入
样例输出
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<stack>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;
ll f[100];
int cnt;
ll n;
int main()
{scanf("%lld",&n);f[1]=1;f[0]=1;cnt=2;while(1){f[cnt]=f[cnt-1]+f[cnt-2];if(f[cnt]>=n){break;}cnt++;}for(int i=cnt;i>=1;i--){if(n==f[i]){printf("%lld",n);return 0;}if(n>f[i]){n-=f[i];}}
}