http://acm.hdu.edu.cn/showproblem.php?pid=2053

Problem Description
There are many lamps in a line. All of them are off at first. A series of operations are carried out on these lamps. On the i-th operation, the lamps whose numbers are the multiple of i change the condition ( on to off and off to on ).
 
Input
Each test case contains only a number n ( 0< n<= 10^5) in a line.
 
Output
Output the condition of the n-th lamp after infinity operations ( 0 - off, 1 - on ).
 
Sample Input
1
5
 
Sample Output
1
0
 
代码:

#include <bits/stdc++.h>

using namespace std;

const int maxn=1e5+10;

int a[maxn];

int A(int n)
{
if(n==0)
return 1;
return 0;
}
int B(int i)
{
for(int j=i;j<=maxn;j+=i)
{
a[j]=A(a[j]);
}
} int main()
{
for(int i=1;i<=1e5;i++)
{
B(i);
}
int n;
while(~scanf("%d",&n))
{
printf("%d\n",a[n]);
}
return 0;
}

  

HDU 2053 Switch Game的更多相关文章

  1. HDU 2053 Switch Game(开灯问题,完全平方数)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2053 题目大意:灯开始是关着的,有n盏灯,i从1数到n每当灯的序号是i的倍数的时候就对灯进行一次操作( ...

  2. hdu 2053 Switch Game 水题一枚,鉴定完毕

    Switch Game Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  3. HDU 3404 Switch lights(Nim积)题解

    题意:在一个二维平面中,有n个灯亮着并告诉你坐标,每回合需要找到一个矩形,这个矩形xy坐标最大的那个角落的点必须是亮着的灯,然后我们把四个角落的灯状态反转,不能操作为败 思路:二维Nim积,看不懂啊, ...

  4. 杭电(hdu)2053 Switch Game 水题

    Switch Game Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Tota ...

  5. HDU 3404 Switch lights 博弈论 nim积

    http://acm.hdu.edu.cn/showproblem.php?pid=3404 题目 http://www.doc88.com/p-5098170314707.html 论文 nim积在 ...

  6. hdu 2053

    Ps:找规律题....凡是平方数都是开...WA了一次..数组给的太小?...后来给到3000..就AC了 代码: #include "stdio.h"long long dp[3 ...

  7. hdu 3404 Switch lights 博弈论

    主要是求NIM积!!! 代码如下: #include<iostream> #include<cstdio> #include<stack> #include< ...

  8. HDOJ 2053 Switch Game

    Problem Description There are many lamps in a line. All of them are off at first. A series of operat ...

  9. HDU 3404&POJ 3533 Nim积(二维&三维)

    (Nim积相关资料来自论文曹钦翔<从"k倍动态减法游戏"出发探究一类组合游戏问题>) 关于Nim积计算的两个函数流程: 代码实现如下: ][]={,,,}; int N ...

随机推荐

  1. Java SE和Java EE应用的性能调优

    凡事预则立,不预则废,和很多事情一样.Java性能调优的成功.离不开行动计划.方法或策略以及特定的领域背景知识.为了在Java性能调优工作中有所成就.你得超越"花似雾中看"的状态, ...

  2. 左侧多级菜单,高亮显示js

    左侧多级菜单,如果本页面是当前栏目,则左侧菜单高亮显示 <ul class="nav navbar-stacked" id="navs"> {ded ...

  3. 在Debian系中快速有效的安装oracle-java

    jre8下载链接  https://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html oracl ...

  4. 从头到尾使用Geth的说明-1-安装

    Geth 1.安装https://github.com/ethereum/go-ethereum/wiki/Installation-Instructions-for-Mac 1.首先先安装Homeb ...

  5. pstart

    下面是我初步的排查过程: [1] [root@71 ~]# tcpdump host 192.168.0.71|grep "IP 115.*"|more tcpdump: verb ...

  6. [转]Qt中定时器使用的两种方法

    Qt中定时器的使用有两种方法,一种是使用QObject类提供的定时器,还有一种就是使用QTimer类. 其精确度一般依赖于操作系统和硬件,但一般支持20ms.下面将分别介绍两种方法来使用定时器. 方法 ...

  7. nginx的反向代理proxy_pass指令

    1. 首先什么是代理服务器?客户机发送请求时,不会直接发送到目的主机,而是先被代理服务器收到,代理服务器收到客服机的请求后,再向目的机发出,目的机就会返回数据给客户机,在返回给客户机之前,会被代理服务 ...

  8. [04] JSP标准动作

    1.概述 JSP规范中定义了一系列的标准动作,Web容器按照规范进行了实现,可以解析并执行标准动作.而标准动作使用的是标准的xml语法,看上去也比较直观易懂,下面来看一个结构例子: <jsp:a ...

  9. 字符串阵列String[]转换为整型阵列Int[]

    原始数据: string input = "3,7,2,8,1,9,1,34,67,78,22"; 要处理为: " }; 最终处理为: , , , , , , , , , ...

  10. odoo11 访问web/database/manager管理数据库页面布局混乱问题

    最近在使用odoo11开发自己的模块时,在管理数据库的页面的时候,页面布局混乱,查看http加载页面的时候大量的js css文件没有加载成功,被卡了3天,现在问题找到. 问题是在加入自己的custom ...