几秒 读完 (大约 70 个字)
                
                
            
         
        
        
            
                【洛谷P2252】取石子游戏
            
        
        
            题解
威佐夫博弈
代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
   | #include<cstdio> #include<algorithm> #include<cmath> #define RG register
  const double Phi((sqrt(5) + 1.) / 2.); int a, b; inline int abs(int a) { return a < 0 ? a : -a; }
  int main() { 	while(~scanf("%d%d", &a, &b)) 	{ 		if(a > b) std::swap(a, b); 		int c = abs(a - b) * Phi; 		if(c == a) puts("0"); 		else puts("1"); 	} 	return 0; }
   |