hdu 2149 巴什博弈
生活随笔
收集整理的這篇文章主要介紹了
hdu 2149 巴什博弈
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
http://acm.hdu.edu.cn/showproblem.php?pid=2149
分析:就是巴什博弈的概念。
題目要求:對于每組數據,在一行里按遞增的順序輸出Lele第一次可以加的價。兩個數據之間用空格隔開。
如果Lele在第一次無論如何出價都無法買到這塊土地,就輸出"none"。
剛剛給人寫留言求教一個問題,剛發完就想明白了。呵呵,我就是這樣的人,傻傻的。
(1)開始還是老規矩先判斷m%(n+1)==0?如果==0的話,lelel必敗,輸出none
(2)當m<n的時候,直接輸出m到n的數肯定滿足條件,是lele贏的。
(3)當m>n的時候,輸出的是m%(n+1).
(1),(3)是巴士博弈求解方法,這題自己分析下多加個條件(2)就行了。哈哈哈,繼續fight.
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){int s;s=n%(m+1);if(s==0){printf("none\n");}else if(n<m){for(int i=n;i<=m;i++){if(i==m)printf("%d",i);elseprintf("%d ",i);}printf("\n");}else printf("%d\n",s);}return 0; }?
轉載于:https://www.cnblogs.com/lanjiangzhou/archive/2013/04/12/3017245.html
總結
以上是生活随笔為你收集整理的hdu 2149 巴什博弈的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: J2SE综合对java util的总结
- 下一篇: 700多位老人的“智慧”养老记