POJ 2368 Buttons(巴什博弈变形)
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std; int a[1005]; int main()
{
int n;
while(~scanf("%d",&n))
{//要后者胜,只要s=0,那么n=(m+1)*r,输出最小的m即可
int len=0;
bool flag=0;
for(int i=1;i*i<=n;i++)//循环应避免TLE
{
if(n%i==0)
{
a[len++]=i;
a[len++]=n/i;
}
}
sort(a,a+len);
for(int i=0;i<len;i++)
{
if(a[i]>2)
{
printf("%d\n",a[i]-1);
flag=1;
break;
}
}
if(!flag)
printf("0\n");
}
return 0;
}
POJ 2368 Buttons(巴什博弈变形)的更多相关文章
- POJ 2368 Buttons
题目链接:http://poj.org/problem?id=2368 Bash game (巴什博弈):当K是(L+1)的倍数时可以确保second player赢.所以这道题要找的就是在K的因子中 ...
- hdu1517A Multiplication Game(巴什博弈变形)
A Multiplication Game Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Ot ...
- nyojb 2359 巴什博弈变形
http://acm.nyist.me/JudgeOnline/problem.php?id=2359 2359: 巴什博弈? 时间限制: 1 Sec 内存限制: 30 MB提交: 237 解决: ...
- hdu 2897 巴什博弈变形 ***
大意:一堆石子共有n个,A,B两人轮流从中取,每次取的石子数必须在[p,q]区间内,若剩下的石子数少于p个,当前取者必须全部取完.最后取石子的人输.给出n,p,q,问先取者是否有必胜策略? Bash博 ...
- (step8.2.7)hdu 1517(A Multiplication Game——巴什博弈变形)
题目大意:输入一个整数n.谁先报的数大于n,谁就输了.(初始值p == 1 , 后一个人报的数必须在前一个人报的数的基础上乘上(2 ~ 9)之间的任意一个数) 解题思路:巴什博奕的变形 1) 解题思 ...
- POJ Georgia and Bob-----阶梯博弈变形。
Georgia and Bob Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 6622 Accepted: 1932 D ...
- HDU 2147kiki's game(巴什博弈变形)
题目链接 思路如下 P : 必胜点,那个人先走到 含P的点,那个这个人一定会输, N:必败点,谁走到这个点谁输! 在这一个题中: 某个点是P还是 N,之与 ⬅️左边第一个点.⬇️下边第一个点.↙️左下 ...
- POJ 2368 巴什博奕
题目大意:给出n个按钮,每次最多可以按L个,按下最后一个按钮的人获胜.求使后手必定获胜的L的最小值(L>=2). 题目思路: 巴什博弈:只有一堆n个物品,两个人轮流从这堆物品中取物,规定每次至少 ...
- POJ 3480 & HDU 1907 John(尼姆博弈变形)
题目链接: PKU:http://poj.org/problem? id=3480 HDU:http://acm.hdu.edu.cn/showproblem.php? pid=1907 Descri ...
随机推荐
- 各种Python小玩意收集
快速排序 quicksort = lambda lst: [] if not lst else quicksort([i for i in lst[1:] if i <= lst[0]]) + ...
- LeetCode 392. Is Subsequence
Given a string s and a string t, check if s is subsequence of t. You may assume that there is only l ...
- leetcode medium
419. Battleships in a Board --No iven an 2D board, count how many different battleships are in it. T ...
- Cracking the Coding Interview 第一章
第一章:数组与字符串 1 数组与字符串 请实现一个算法,确定一个字符串的所有字符是否全都不同.这里我们要求不允许使用额外的存储结构. 给定一个string iniString,请返回一个bool值,T ...
- C#数字类型及运算符
- XTU 1250 Super Fast Fourier Transform
$2016$长城信息杯中国大学生程序设计竞赛中南邀请赛$H$题 排序,二分. 对$a$数组,$b$数组从小到大进行排序. 统计每一个$a[i]$作为较大值的时候与$b[i]$对答案的贡献.反过来再统计 ...
- urllib模块 | Python 2.7.11
官方文档: https://docs.python.org/2/library/urllib.html 某博客对官方文档较全的翻译: http://h2byte.com/post/tech/relat ...
- docker容器安全
title: docker容器安全 tags: Docker,容器,安全策略 grammar_cjkRuby: true --- Docker容器的安全性 1.安全策略-Cgroup 1.限制Cpu ...
- 《Intel汇编第5版》 数组求和
一.LOOP指令 二.间接寻址 三.汇编数组求和 INCLUDE Irvine32.inc includelib Irvine32.lib includelib kernel32.lib includ ...
- sql第一天
关系数据库中的关系指的就是表 table 表 Column 列 Field 字段 Row 行 非空约束 not null 主键约束(PK)primary key constraint 唯 ...