Scenario 1: Whoever takes the light at the end wins
Anyone who has played one of the types of Bash games knows that n stones are given to you, and two people take turns to take it. It is stipulated that each person will take at least one at a time and at most m. win, and assume that both parties use the optimal strategy.
Analysis, if the last one left to the opponent is m+1, then the opponent will take at most m, and at least 1, then the last player must be himself, then if the opponent faces (m+1) before each take The multiple of , that is, no matter how much the opponent takes next, he can always make up so that the number of stones taken by two people only sums up to (m+1). Finally, the opponent will face the situation of m+1 stones, that is, he will definitely take the last stone. over
That is, if you are the first mover, then if n%(m+1)==0, that is, you are faced with a multiple of (m+1), and you will lose if both parties adopt the best strategy.
If n%(m+1)! =0, then you will take n%(m+1) of them, so that the opponent faces a multiple of (m+1), that is, the opponent will definitely lose in the end
Scenario 2: The one who takes the light at the end loses
If there is only one stone left when your opponent takes at the end, because at least one is taken, then your opponent must have taken all, then the opponent must lose, that is, whoever takes n-1 stones first will win, then Reference Scenario 1 If you move first, and (n-1)%(m+1)==0, then you will definitely lose, otherwise your opponent will definitely lose
Special case:
if m>=n
That is to say, it can be taken at one time. In case one, the first mover must win. If n=1 at this time, then in case two, the first mover must lose, otherwise the second mover must lose.
Stone
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2144 Accepted Submission(s): 1511
#include<iostream> using namespace std; intmain() { int n,m; while(cin>>n>>m&&n>0) { if((n-1)%(m+1)!=0) cout<<"Tang"<<endl; else cout<<"Jiang"<<endl; } }
Public Sale
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 10000 Accepted Submission(s): 5957
To farm, you need to have a field. Lele heard that a special auction is being held on the street. The auction item happens to be a 20-acre field. So, Lele took all his savings and rushed to the auction.
It was later discovered that the entire auction consisted of Lele and his nemesis Yueyue.
Through inquiries, Lele knows that the rules of this auction are as follows: at the beginning, the reserve price is 0, and two people take turns to increase the price, but the range of each increase should be between 1 and N. When the price is greater than or equal to the cost price M of the field , the organizer sold the field to the bidder.
Although Lele and Yueyue failed the exams, they were very proficient at auctions, and both of them wanted the land very much. So they choose the most favorable way to increase the price every time.
Since Lele's lexicographical order is higher than Yueyue's, Lele starts to increase the price every time. Excuse me, when the price is increased for the first time,
how much does Lele have to pay to ensure that he can buy this land?
Each set of tests contains two integers M and N (see the title description for the meaning, 0<N, M<1100)
If Lele can't buy the land on the first bid no matter what, output "none".
#include<iostream> using namespace std; int r[10000]; int ri=0; int main() { int n,m; while(cin>>n>>m) { ri=0; if(n%(m+1)!=0) { for(int i=1;i<=m;i++) { if((n-i)%(m+1)==0||n-i<=0) r[ri++]=i; } for(int i=0;i<ri-1;i++) cout<<r[i]<<" "; cout<<r[ri-1]; cout<<endl; } else cout<<"none"<<endl; } }
Good Luck in CET-4 Everybody!
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 12163 Accepted Submission(s): 7882
“升级”?“双扣”?“红五”?还是“斗地主”?
当然都不是!那多俗啊~
作为计算机学院的学生,Kiki和Cici打牌的时候可没忘记专业,她们打牌的规则是这样的:
1、 总共n张牌;
2、 双方轮流抓牌;
3、 每人每次抓牌的个数只能是2的幂次(即:1,2,4,8,16…)
4、 抓完牌,胜负结果也出来了:最后抓完牌的人为胜者;
假设Kiki和Cici都是足够聪明(其实不用假设,哪有不聪明的学生~),并且每次都是Kiki先抓牌,请问谁能赢呢?
当然,打牌无论谁赢都问题不大,重要的是马上到来的CET-4能有好的状态。
Good luck in CET-4 everybody!
#include<iostream> using namespace std; int main() { int n; while(cin>>n) { if(n%3==0) cout<<"Cici"<<endl; else cout<<"Kiki"<<endl; } }