ZOJ 1893 A Multiplication Game 【简单博弈】
感觉ZJU上有不少博弈的题目。
这道题目还是比较好理解的,题目大概意思是:两人轮流乘一个2-9的数,从1开始乘,求谁的乘积先大于N。
还是寻找必败点必胜点,不过在这个题目里转换成了寻找必败区间必胜区间的问题
以输入1000为例,我们可以倒着来,每个人除2到9之间的一个数
1000 | 999 ... 112 | 若占住999到112,则对手必胜。 必须让对手占领此段。
1000 | 999 ... 112 | 111 ... 56 | 因此必占段是 111 -? 。如果56被对手占住,则56×2=112,入必败段。问题转化成为占56。
如此循环。如下 1000 | 999 ... 112 | 111 ... 56 | 55 ... 7 | 6 ... 4 | 3 ... 1
| 必胜区间 | 必败区间 | 胜 | 败 | 胜
到此,思路已经非常明显。
Source Code:
//#pragma comment(linker, "/STACK:16777216") //for c++ Compiler
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <cstring>
#include <cmath>
#include <stack>
#include <string>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <vector>
#include <algorithm>
#define Max(a,b) (((a) > (b)) ? (a) : (b))
#define Min(a,b) (((a) < (b)) ? (a) : (b))
#define Abs(x) (((x) > 0) ? (x) : (-(x)))
#define MOD 1000000007
#define pi acos(-1.0) using namespace std; typedef long long ll ;
typedef unsigned long long ull ;
typedef unsigned int uint ;
typedef unsigned char uchar ; template<class T> inline void checkmin(T &a,T b){if(a>b) a=b;}
template<class T> inline void checkmax(T &a,T b){if(a<b) a=b;} const double eps = 1e- ;
const int N = ;
const int M = ;
const ll P = 10000000097ll ;
const int INF = 0x3f3f3f3f ; int main(){
int i, j, t, n, m, k;
while(cin >> n){
bool flag = true;
while(n > ){
if(flag){
if(n % == ) n /= ;
else n = n / + ;
} else{
if(n % == ) n /= ;
else n = n / + ;
}
flag =! flag;
}
if(!flag)
cout << "Stan wins." << endl;
else
cout << "Ollie wins." << endl; }
return ;
}
ZOJ 1893 A Multiplication Game 【简单博弈】的更多相关文章
- ACM: NBUT 1107 盒子游戏 - 简单博弈
NBUT 1107 盒子游戏 Time Limit:1000MS Memory Limit:65535KB 64bit IO Format: Practice Appoint ...
- HDU 1564 简单博弈 水
n*n棋盘,初始左上角有一个石头,每次放只能在相邻的四个位置之一,不能操作者输. 如果以初始石头编号为1作为后手,那么对于每次先手胜的情况其最后一步的四周的编号必定是奇数,且此时编号为偶数,而对于一个 ...
- HDU 1079 Calendar Game(简单博弈)
Calendar Game Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- poj 2505 A multiplication game(博弈)
A multiplication game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5622 Accepted: ...
- hdu 1846 Brave Game 简单博弈
Problem Description 十年前读大学的时候,中国每年都要从国外引进一些电影大片,其中有一部电影就叫<勇敢者的游戏>(英文名称:Zathura),一直到现在,我依然对于电影中 ...
- HDU 4642 Fliping game (2013多校4 1011 简单博弈)
Fliping game Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tota ...
- [POJ1082&POJ2348&POJ1067&POJ2505&POJ1960]简单博弈题总结
鉴于时间紧张...虽然知道博弈是个大课题但是花一个上午时间已经极限了... 希望省选过后再回过头来好好总结一遍吧. 接下来为了看着顺眼一点...还是按照难度顺序吧 POJ1082 一道最简单的博弈 ...
- acm之简单博弈 Nim Bash Wythoff
前些日子我打算开了博弈基础,事后想进行总结下 一句话就是分析必胜或必败,异或为0. 以下内容来自转载: Nim游戏的概述: 还记得这个游戏吗?给出n列珍珠,两人轮流取珍珠,每次在某一列中取至少1颗珍珠 ...
- BZOJ 1034 泡泡堂BNB 贪心+简单博弈
同样是今天做bzoj时做到的,感觉能力范围之内的就做了,也是蛮简单的 1034: [ZJOI2008]泡泡堂BNB Time Limit: 10 Sec Memory Limit: 162 MB Su ...
随机推荐
- excel读入数据库
POI3.9效率大幅度提高,支持xls以及xlsx. 首先需要POI的JAR包,MAVEN配置如下: <!-- excel start --> <dependency> < ...
- Sublime Text2
Ctrl+L选择整行(按住-继续选择下行) Ctrl+KK 从光标处删除至行尾 Ctrl+Shift+K 删除整行 Ctrl+Shift+D 复制光标所在整行,插入在该行之前 Ctrl+J 合并行(已 ...
- 干Inlay的生产过程
•天线的组成 天线的材料有0.38PET和0.16以及0.3的铝箔组成. 倒封装 •将IC倒装在天线焊盘位置. •方法:先点胶水, 然后把IC对准焊盘(IC一面有凸点),通过热压把IC 固定在焊盘上. ...
- [Windows编程] #pragma once 和#ifndef ... #define ... #endif 比较
C++中防止头文件被多次include 的常见方式有: 1) 用#ifndef ... #define ... #endif 宏 #ifndef __MYHEADER_H__#define __M ...
- mfc删除标题和边框
//删除标题和边框WS_CAPTION和WS_BORDER风格 ModifyStyle(WS_CAPTION, 0);ModifyStyle(WS_BORDER, 0);
- C++模板:二分查找
bool find(int x,int l,int r){ if(l>r)return false; int mid=(l+r)/2; if(s[mid]==x) return true; el ...
- PhoneGap 3.0 安装
PhoneGap 3.0 已经出来有一段时间了.3.0 提供了使用Node.js 安装,使用命令行创建.编译.运行项目.也就是可以抛弃eclipse,完全使用命令.记事本开发phonegap 项目了 ...
- opencv中遇到的的一些错误
一:错误提示:OpenCV Error:Bad argument<src and dst have different formats> in unkown function,file.. ...
- 遇见Lambda
转自:http://www.cnblogs.com/allenlooplee/archive/2012/07/03/2574119.html 在学习generate时候发现C++中的匿名函数,上面博文 ...
- Linux下安装JRE
(1)下载jre-7u5-linux-i586.tar.gz,上传至/root目录 (2)执行tar -zxf jre-7u5-linux-i586.tar.gz (3)mv jre1.7.0_05 ...