标签:tput target 个数 ecif over integer vector specific AC
巴什博弈:
Tang and Jiang are good friends. To decide whose treat it is for dinner, they are playing a game. Specifically, Tang and Jiang will alternatively write numbers (integers) on a white board. Tang writes first, then Jiang, then again Tang, etc... Moreover, assuming that the number written in the previous round is X, the next person who plays should write a number Y such that 1 <= Y - X <= k. The person who writes a number no smaller than N first will lose the game. Note that in the first round, Tang can write a number only within range [1, k] (both inclusive). You can assume that Tang and Jiang will always be playing optimally, as they are both very smart students.
InputThere are multiple test cases. For each test case, there will be one line of input having two integers N (0 < N <= 10^8) and k (0 < k <= 100). Input terminates when both N and k are zero.
OutputFor each case, print the winner‘s name in a single line.
Sample Input
1 1 30 3 10 2 0 0
Sample Output
Jiang Tang Jiang
#include <iostream> #include<cstdio> #include<cstring> #include<queue> #include<vector> #define ll long long int using namespace std; int main() { int n,m; while(scanf("%d%d",&n,&m)==2) { if(n==0&&m==0) break; if( !( (n-1)%(m+1) ) ) printf("Jiang\n"); else printf("Tang\n"); } return 0; }
摘自于:https://blog.csdn.net/u011613321/article/details/12142861
威佐夫博弈:
Input输入包含若干行,表示若干种石子的初始情况,其中每一行包含两个非负整数a和b,表示两堆石子的数目,a和b都不大于1,000,000,000。Output输出对应也有若干行,每行包含一个数字1或0,如果最后你是胜者,则为1,反之,则为0。Sample Input
2 1 8 4 4 7
Sample Output
0 1 0
#include<iostream> #include<cmath> #include<cstdio> using namespace std; double p=(sqrt((double)5)+1)/double(2); int main (){ int a,b,c; while(scanf("%d%d",&a,&b)!=EOF){ c=abs(a-b); a=a>b?b:a; if(a==(int)(p*c)) printf("0\n"); else printf("1\n"); } return 0; }
摘自于:https://blog.csdn.net/dgq8211/article/details/7397876
菲波那切博弈:
Input输入有多组.每组第1行是2<=n<2^31. n=0退出.
Output先取者负输出"Second win". 先取者胜输出"First win".
参看Sample Output.
Sample Input
2 13 10000 0
#include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> #include <climits> using namespace std; int a,b; int main() { int n,ts; bool mark; while(scanf("%d",&n) && n){ a = 2,b = 3; mark = false; while(a<=n){ if(a==n || b==n){ mark = true; break; } ts = (a + b); a = b; b = ts; } if(mark){ printf("Second win\n"); }else{ printf("First win\n"); } } return 0; }
加深理解请戳这里 >> https://www.cnblogs.com/jiu0821/p/4638165.html <<
博弈论大佬们的博客链接:https://blog.csdn.net/jxjyjx5/article/details/53945608
https://blog.csdn.net/baidu_36394995/article/details/76206979
标签:tput target 个数 ecif over integer vector specific AC
原文地址:https://www.cnblogs.com/coder-tcm/p/8905868.html