hdu 1525找规律博弈
来源:互联网 发布:义乌美工培训多少钱 编辑:程序博客网 时间:2024/05/18 12:04
题意:给你两个数,每次可以拿大的那个数减去小的那个数的正整数倍,只要减去后得到的数是正的或者0就行,谁先得到其中一个数是0,谁就胜出。
我们会发现,假设a>b,如果a/b>=2,那么后面就会出现a/b种路线,当a/b=1的时候只有一种路线,所以谁到了a/b>=2这个局面就有必胜策略,此外,当a%b==0的时候,就直接跳出来了,也是必胜点。
View Code
// I'm lanjiangzhou//C#include <stdio.h>#include <stdlib.h>#include <string.h>#include <ctype.h>#include <math.h>#include <time.h>//C++#include <iostream>#include <algorithm>#include <cstdio>#include <cstdlib>#include <cmath>#include <cstring>#include <cctype>#include <stack>#include <string>#include <list>#include <queue>#include <map>#include <vector>#include <deque>#include <set>using namespace std;//*************************OUTPUT*************************#ifdef WIN32#define INT64 "%I64d"#define UINT64 "%I64u"#else#define INT64 "%lld"#define UINT64 "%llu"#endif//**************************CONSTANT***********************#define INF 0x3f3f3f3f// aply for the memory of the stack//#pragma comment (linker, "/STACK:1024000000,1024000000")//endint main(){ int n,m; while(scanf("%d%d",&n,&m)!=EOF){ if(n==0&&m==0) break; bool stan=true; while(1){ if(n<m){ int t=n; n=m; m=t; } if(n==0||m==0||(n/m>=2)||(n%m==0)) break; n=n%m; stan=!stan; } if(stan) printf("Stan wins\n"); else printf("Ollie wins\n"); } return 0;}
- hdu 1525找规律博弈
- hdu 1847 博弈找规律
- hdu 2147博弈找规律
- hdu 2516博弈找规律
- HDU 2147博弈-找规律
- hdu 5708 博弈找规律
- HDU 1525 Euclid's Game (博弈、找规律)*
- HDU 1525 Euclid's Game【博弈 PN找规律】
- HDU 1525 Euclid's Game 找规律博弈
- hdu 1564 博弈找规律(水题)
- HDU 3389 Game(博弈 Nim 找规律)
- hdu 1729 Stone Game 【博弈-找规律】
- HDU 3389 Game(博弈 Nim 找规律)
- HDU 5963 朋友 (博弈、找规律)
- HDU-1079 Calendar Game(找规律,博弈)
- [HDU](2147)kiki's game ---找规律博弈(博弈)
- HDOJ1525 [找规律博弈]
- hdu1079 找规律/博弈
- (转载)尼姆游戏的变形
- hdu1907||poj3480 sg博弈
- hdu 2509 sg博弈
- &运算符
- (转载)Nim游戏博弈(收集完全版)
- hdu 1525找规律博弈
- hdu 1564 博弈找规律(水题)
- poj 2234基础Nim博弈||sg博弈
- hdu 1847 博弈找规律
- hdu 2147博弈找规律
- hdu 2516博弈找规律
- hdu 1849 nim博弈
- 【异常】java.net.SocketException: Permission denied 解决方法
- (转载)博弈之SG函数