标签:iostream logs stream cout str cin end swap 2.0
有两堆各若干个物品,两个人轮流从某一堆或同时从两堆中取同样多的物品,规定每次至少取一个,多者不限,最后取光者得胜。
a b 两堆 a >= b
奇异局势 (a - b) * (1 + sqrt(5)) / 2.0) == a
黄金分割数(1+√5)/2 = 1.618...
1 #include <iostream> 2 #include <cmath> 3 using namespace std; 4 int main(){ 5 int a, b; 6 while(cin >> a >> b){ 7 if(a < b) swap(a, b); 8 int cmp = (a - b) * (1 + sqrt(5) / 2); 9 if(cmp == a){ 10 cout << ‘A‘ << endl; 11 } 12 else cout << ‘B‘ << endl; 13 } 14 }
标签:iostream logs stream cout str cin end swap 2.0
原文地址:http://www.cnblogs.com/jxust-jiege666/p/6662222.html