小明和小王在玩一个乘法游戏。游戏的每一轮需要将2~9中的某一个数字和已经得到的数p乘起来。小明总是从p=1开始乘,然后是小王,接下来是小明,如此往复。在游戏开始之前,他们写下了一个整数n(1<n<42949000),得出的乘积p首次满足p≥n的游戏者获胜。
输入
输入每行包含一个整数n。
输出
对于每行输入,输出一行,要么是
小明 wins.
要么是
小王 wins.
假设双方都采取最优策略。
输入 输出
162 小明 wins.
17 小王wins.
34012226 小明 wins.
求解这个的C++或者C语言编译过程。
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
2条回答 默认 最新
- fuill 2022-06-15 07:25关注
参考这个https://blog.csdn.net/new_wu/article/details/7394311
原文代码#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <vector> #include <queue> #include <cmath> #include <string> #include <cctype> #include <map> #include <iomanip> using namespace std; #define eps 1e-8 #define pi acos(-1.0) #define inf 1<<30 #define linf 1LL<<60 #define pb push_back #define lc(x) (x << 1) #define rc(x) (x << 1 | 1) #define lowbit(x) (x & (-x)) #define ll long long double n; int main(){ while(~scanf("%lf",&n)){ while(n>18) n=n/18; if(n<=9) printf("Stan wins.\n"); else printf("Ollie wins.\n"); } return 0; }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 1无用
悬赏问题
- ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
- ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
- ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
- ¥15 如何在炒股软件中,爬到我想看的日k线
- ¥15 seatunnel 怎么配置Elasticsearch
- ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
- ¥15 (标签-MATLAB|关键词-多址)
- ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
- ¥500 52810做蓝牙接受端
- ¥15 基于PLC的三轴机械手程序