hdu2486 hdu2580 poj3922 A simple stone game-K倍儿动态减法游戏 博弈
hdu2486 hdu2580 poj3922A simple stone game--K倍动态减法游戏博弈A simple stone gameTime Limit: 2000/
hdu2486 hdu2580 poj3922 A simple stone game--K倍动态减法游戏 博弈
A simple stone gameTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 182 Accepted Submission(s): 86
Problem DescriptionInputOutputSample InputSample OutputSourceRecommend#include<iostream>#include<cstdlib>#include<stdio.h>using namespace std;const int N=2000000;int a[N],b[N];int main(){ int t,n,k; int count=1; scanf("%d",&t); while(t--) { scanf("%d%d",&n,&k); a[0]=b[0]=1; int i=0,j=0; while(a[i]<n) { i++; a[i]=b[i-1]+1; while(a[j+1]*k<a[i]) j++; if(a[j]*k<a[i]) b[i]=b[j]+a[i]; else b[i]=a[i]; } printf("Case %d: ",count++); if(a[i]==n) puts("lose"); else { int ans; while(n) { if(n>=a[i]) { n-=a[i]; ans=a[i]; } i--; } cout<<ans<<endl; } }}