1070 Bash游戏 V4
生活随笔
收集整理的這篇文章主要介紹了
1070 Bash游戏 V4
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1070 Bash游戲?V4
有一堆石子共有N個。A B兩個人輪流拿,A先拿。每次拿的數量最少1個,最多不超過對手上一次拿的數量的2倍(A第1次拿時要求不能全拿走)。拿到最后1顆石子的人獲勝。假設A B都非常聰明,拿石子的過程中不會出現失誤。給出N,問最后誰能贏得比賽。 例如N = 3。A只能拿1顆或2顆,所以B可以拿到最后1顆石子。 Input 第1行:一個數T,表示后面用作輸入測試的數的數量。(1?<=?T?<=?1000) 第2?-?T?+?1行:每行1個數N。(1?<=?N?<=?10^9) Output 共T行,如果A獲勝輸出A,如果B獲勝輸出B。 Input示例 3 2 3 4 Output示例 B B A從1到10算下可以猜出就是斐波那契數列。 1 #include <bits/stdc++.h> 2 using namespace std; 3 #define ll long long 4 const int N = 1e5+10; 5 set<ll> st; 6 void init() { 7 st.insert(1); 8 st.insert(2); 9 int x = 1, y = 2; 10 for(int i = 1; i < N; i ++) { 11 st.insert(x + y); 12 y = y + x; 13 x = y - x; 14 } 15 } 16 int main() { 17 init(); 18 int t; 19 ll n; 20 cin >> t; 21 while(t--) { 22 cin >> n; 23 if(st.count(n)) printf("B\n"); 24 else printf("A\n"); 25 } 26 return 0; 27 }
?
轉載于:https://www.cnblogs.com/xingkongyihao/p/7616565.html
總結
以上是生活随笔為你收集整理的1070 Bash游戏 V4的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: JFinal常量配置学习笔记
- 下一篇: linux 安装swoole