POJ 2505 A multiplication game(找规律博弈/贪心)
#include<iostream> #include<cstdio> using namespace std; typedef long long ll; int main() { ll n; while(~scanf("%I64d",&n)) {//其实算是 贪心了吧 //先手想赢,他会x2,这样子才能尽量避免让后手赢 //后手想赢,他就会x9,只有乘最大的,他胜算才最大 int t=0; ll l=1,r=9; while(1) { if(n>=l&&n<=r) break; l=r+1; if(t%2==0) r*=2; else r*=9; t++; } if(t%2==0) printf("Stan wins.\n"); else printf("Ollie wins.\n"); } return 0; }