HDU 3951 Coin Game
这个题要分情况讨论:
就是当k>=n时,first一定赢;
当k==1时,当k为奇数时,first赢,反则second赢;
当k<n&&k!=1一定是second赢,因为每次无论first怎么取,second一定可以使之对称并且是偶数个;
那么second一定会赢;
View Code
#include<iostream> #include<cstdio> #include<cstdlib> #include<algorithm> #include<cmath> #include<queue> #include<set> #include<map> #include<cstring> #include<vector> #include<string> #define LL long long using namespace std; int main( ) { int n,k,T; scanf( "%d",&T ); for( int i = 1; i <= T; i ++ ) { scanf( "%d %d",&n,&k ); printf( "Case %d: ",i ); if( k >= n ||( k == 1 && n % 2 == 1 ) ) puts( "first" ); else puts( "second" ); } //system( "pause" ); return 0; }