110505 A multiplication game
来源:互联网 发布:网上礼佛软件 编辑:程序博客网 时间:2024/05/18 02:53
This solution gets "Wrong answer" result inhttp://www.programming-challenges.com/,
but it gets "Accepted" result inhttp://uva.onlinejudge.org/.
I don't know why so far.
#include <math.h>#include <iostream>using namespace std;#define MIN 2.0#define MAX 9.0enum Result_t{STAN,OLLIE};enum Target_t{NOT_LESS_THAN_AND_FIND_WINNER,LESS_THAN_AND_FIND_LOSER};static void OutputResult(Result_t result){switch(result){case STAN:cout << "Stan";break;default:cout << "Ollie";}cout << " wins." << endl;}static Result_t GetOppositeResult(Result_t result){switch(result){case STAN:return OLLIE;default:return STAN;}}static Result_t RunGame(unsigned long long n, Target_t target){if (NOT_LESS_THAN_AND_FIND_WINNER == target){// Find Winner.if (n <= 9)return STAN;if ((9 < n) && (n < (9 * 2)))return OLLIE;if (((2 * 2 * 9) <= n) && (n < (9 * 9 * 2)))return STAN;return GetOppositeResult(RunGame(ceil((double)n / MAX), LESS_THAN_AND_FIND_LOSER));}else // if (LESS_THAN_AND_FIND_LOSER == target){// Find Loserif (n <= 2)return STAN;if ((2 < n) && (n < (9 * 2)))return OLLIE;return GetOppositeResult(RunGame(ceil((double)n / MIN), NOT_LESS_THAN_AND_FIND_WINNER));}}static void Test(){unsigned long long n;while(cin >> n)OutputResult(RunGame(n, NOT_LESS_THAN_AND_FIND_WINNER));}int main(int argc, char* argv[]){Test();return 0;}
- 110505 A multiplication game
- programming-challenges A multiplication game (110505) 题解
- A Multiplication Game
- HDU1517-A Multiplication Game
- A Multiplication Game
- poj2505 - A multiplication game
- A Multiplication Game + 博弈
- 847 - A Multiplication Game
- hdu1517 A Multiplication Game
- 【poj2505】A multiplication game
- A multiplication game
- A Multiplication Game
- A multiplication game
- hdu1517 A Multiplication Game
- hdu1517 A Multiplication Game
- [博弈] A Multiplication Game
- A Multiplication Game 博弈
- fjnu 1550 A multiplication game
- STL中map按值排序
- Qt中路径问题一般解决办法
- UIWebview
- 3.17 基于OHCI的USB主机 —— 中断处理程序
- keytool生成证书
- 110505 A multiplication game
- 修改mini2440的软MAC地址
- extjs form submit upload 返回下载download 没有回调
- 4.1 随便说几句 —— 关于USB主机系列
- TLD学习资料blog汇总
- try catch异常处理与SEH
- 加载驱动,取得connection的util文件
- JSON跨域请求
- 处理home按键清空Activity所在的Task堆栈