Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 5536 Accepted Submission(s): 3151

Problem Description

Stan and Ollie play the game of multiplication by multiplying an integer p by one of the numbers 2 to 9. Stan always starts with p = 1, does his multiplication, then Ollie multiplies the number, then Stan and so on. Before a game starts, they draw an integer 1 < n < 4294967295 and the winner is who first reaches p >= n.

Input

Each line of input contains one integer number n.

Output

For each line of input output one line either

Stan wins.

or

Ollie wins.

assuming that both of them play perfectly.

Sample Input

162

17

34012226

Sample Output

Stan wins.

Ollie wins.

Stan wins.

【题目链接】:http://acm.hdu.edu.cn/showproblem.php?pid=1517

【题解】



用sg函数容易推出来小数据的答案;

如下”()”表示先手赢而”{}”表示先手输



一开始l = 2,r = 9;

递推的话

l = r+1;

如果这次是先手赢

则接下来是先手输的态

r = r*2;

如果这次是先手输

则接下来是先手赢的态

r = r*9;

(感性理解:让先手输比较难)



【完整代码】

#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rei(x) scanf("%d",&x)
#define rel(x) scanf("%I64d",&x) typedef pair<int,int> pii;
typedef pair<LL,LL> pll; //const int MAXN = x;
const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0); LL n; int main()
{
//freopen("F:\\rush.txt","r",stdin);
while (~scanf("%I64d",&n))
{
int now = 1;
LL l = 2,r = 9;
while (true)
{
if (l<=n && n <= r)
break;
l = r+1;
if (now==1)
r = r*2;
else
r = r*9;
now ^= 1;
}
if (now)
puts("Stan wins.");
else
puts("Ollie wins.");
}
return 0;
}

最新文章

  1. HTML5 Application cache初探和企业应用启示
  2. setTimeout 和 setInterval
  3. 这是经典的&quot;百马百担&quot;问题,有一百匹马,驮一百担货,大马驮3担,中马驮2担,两只小马驮1担,问有大,中,小马各几匹?
  4. HDU 4352 XHXJ&#39;s LIS
  5. ef执行记录原生态代码方法。
  6. C#连接MySql数据库的方法
  7. ASP.NET SignalR 与LayIM配合,轻松实现网站客服聊天室(二) 实现聊天室连接
  8. Java Hour 9
  9. ISNULL
  10. 该项目中不存在目标 precomputecompiletypescript The target &quot;PreComputeCompileTypeScript&quot; does not exist in the project
  11. Android手机安全软件的恶意程序检测靠谱吗--LBE安全大师、腾讯手机管家、360手机卫士恶意软件检测方法研究
  12. js实现选项卡切换的效果
  13. DOM元素拖拽效果
  14. mvc约定
  15. 手动安装cloudera manager 5.x(tar包方式)详解
  16. bind啊你返回的函数到底是个虾米
  17. OA流程分析
  18. 基于Python的机器学习实战:KNN
  19. sql server连接字符串与tcp/ip开启
  20. C#6.0语言规范(十八) 不安全代码

热门文章

  1. java poi 向excel写入图片
  2. 【前端图表】echarts散点图鼠标划过散点显示信息
  3. 关于JS面向对象、设计模式、以及继承的问题总结
  4. php杂项函数
  5. struts2笔记---struts2的执行过程
  6. uiview关联xib
  7. 【习题 5-2 UVA-1594】Ducci Sequence
  8. PatentTips - Transitioning between virtual machine monitor domains in a virtual machine environment
  9. [RxJS] Multicasting shortcuts: publish() and variants
  10. std::的概念与作用