题目链接:http://poj.org/problem?id=2368

Bash game (巴什博弈):当K是(L+1)的倍数时可以确保second player赢。所以这道题要找的就是在K的因子中有没有大于2的因子。代码如下:

 #include <iostream>
#include <math.h>
#include <stdio.h>
#include <cstdio>
#include <algorithm>
#include <string.h>
#include <string>
#include <sstream>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <cmath>
#include <set>
#define SCF(a) scanf("%d", &a)
#define IN(a) cin>>a
#define FOR(i, a, b) for(int i=a;i<b;i++)
#define Infinity 999999999
#define NInfinity -999999999
#define PI 3.14159265358979323846
typedef long long Int;
using namespace std; int main()
{
int K;
int a;
int factor[];
while (SCF(K) != EOF)
{
int len = ;
for (a = ; a*a <= K; a++)
{
if (K % a == )
{
factor[len++] = a;
factor[len++] = K / a;
}
}
sort(factor, factor + len);
bool found = false;
FOR(i, , len)
{
if (factor[i] > )
{
printf("%d\n", factor[i]-);
found = true;
break;
}
}
if (!found)
printf("0\n");
}
return ;
}

POJ 2368 Buttons的更多相关文章

  1. POJ 2368 Buttons(巴什博弈变形)

    题目链接 #include<iostream> #include<cstdio> #include<algorithm> using namespace std; ...

  2. POJ 2368 巴什博奕

    题目大意:给出n个按钮,每次最多可以按L个,按下最后一个按钮的人获胜.求使后手必定获胜的L的最小值(L>=2). 题目思路: 巴什博弈:只有一堆n个物品,两个人轮流从这堆物品中取物,规定每次至少 ...

  3. poj2368 Buttons Nim取石子游戏

    链接:http://poj.org/problem?id=2368 和前面差距还是很大啊囧 代码: k,a;main(i){,i=;i<=k/&&k%i;++i);k%i||(a ...

  4. poj 1176 Party Lamps

    http://poj.org/problem?id=1176 Party Lamps Time Limit: 1000MS   Memory Limit: 10000K Total Submissio ...

  5. poj 题目分类(1)

    poj 题目分类 按照ac的代码长度分类(主要参考最短代码和自己写的代码) 短代码:0.01K--0.50K:中短代码:0.51K--1.00K:中等代码量:1.01K--2.00K:长代码:2.01 ...

  6. POJ题目分类(按初级\中级\高级等分类,有助于大家根据个人情况学习)

    本文来自:http://www.cppblog.com/snowshine09/archive/2011/08/02/152272.spx 多版本的POJ分类 流传最广的一种分类: 初期: 一.基本算 ...

  7. POJ题目细究

    acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP:  1011   NTA                 简单题  1013   Great Equipment     简单题  102 ...

  8. 转载:poj题目分类(侵删)

    转载:from: POJ:http://blog.csdn.net/qq_28236309/article/details/47818407 按照ac的代码长度分类(主要参考最短代码和自己写的代码)  ...

  9. 【POJ】1222 EXTENDED LIGHTS OUT(高斯消元)

    http://poj.org/problem?id=1222 竟然我理解了两天..... 首先先来了解异或方程组(或者说mod2方程组,modk的话貌似可以这样拓展出来) 对于一些我们需要求出的变量a ...

随机推荐

  1. tomcat启动成功后访问却404

    1.检查是否把项目添加进tomcat,好久不用tomcat这次就犯了这种低级错误 2.检查路径,tomcat中的访问路径与项目中设置的路径是否一样,因为这次有些配置文件直接复制的源码,但源码中项目名称 ...

  2. SSM的搭建

    1.首先是工具的准备. eclipse jdk1.7 maven 3.5.4 tomcat 8.5 2.工具环境的搭建 首先,new建立选择maven project工程,勾选simple proje ...

  3. 手动(原生ajax)和自动发送ajax请求 伪ajax(Ifrname)

    自动发送  ---> 依赖jQuery文件 实例-->GET请求: function AjaxSubmit() { $.ajax({ url:'/data', type:"GET ...

  4. springboot 开启事务以及手动提交事务

    添加依赖,sprongboot 会默认开启事务管理 org.springframework.boot spring-boot-starter-jdbc 在需要的服务类里添加注解 @Autowired ...

  5. 云栖大会day1 下午

    下午参与的是创新创业专场 会议议程是 创新创业专场-2018阿里云创新中心年度盛典 13:30-14:10 阿里双创新征程 李中雨 阿里云创业孵化事业部总经理 14:10-14:40 人货场的渗透与重 ...

  6. Java学习--数组--判断数组中是否包含某个元素的方法

    package zaLearnpackage; import org.apache.commons.lang3.ArrayUtils; import java.util.Arrays; import ...

  7. time_wait的快速回收和重用

    TCP四次挥手: Time_wait产生原因及作用: 1. time_wait状态如何产生? 由上面的变迁图,首先调用close()发起主动关闭的一方,在发送最后一个ACK之后会进入time_wait ...

  8. MFC列表控件更改一行的字体颜色

    参考自(http://blog.csdn.net/ribut9225/article/details/6720639) 1.首先从CListCtrl 继承一个类,命名为CListCtrlCl 在头文件 ...

  9. H5-手机震动

    //手机震动function vibration(){ navigator.vibrate = navigator.vibrate || navigator.webkitVibrate || navi ...

  10. JUnit源码分析 - 扩展 - 自定义Rule

    JUnit Rule简述 Rule是JUnit 4.7之后新加入的特性,有点类似于拦截器,可以在测试类或测试方法执行前后添加额外的处理,本质上是对@BeforeClass, @AfterClass, ...