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. 【转】curl 命令行下载工具使用方法小结

    获取curl curl 命令行下载工具 curl的官方网站为: http://curl.haxx.se官方下载页面为:http://curl.haxx.se/download.html 你可能并不清楚 ...

  2. wifi 安卓手机

    通过wifi向服务器端发送数据 https://www.cnblogs.com/zhaoxinshanwei/p/3573813.html http://www.hx-wl.com.cn/51wifi ...

  3. Centos 6.5 pptpd服务端搭建过程

    首先检测有没有启用ppp和tun cat /dev/ppp cat /dev/net/tun 如果显示是这样的 cat: /dev/ppp: No such device or address cat ...

  4. P1160 队列安排 luogu洛谷

    题目描述 一个学校里老师要将班上NNN个同学排成一列,同学被编号为1∼N1\sim N1∼N,他采取如下的方法: 先将111号同学安排进队列,这时队列中只有他一个人: 2−N2-N2−N号同学依次入列 ...

  5. 关于Nginx

    访问 www.a.com 自动跳到 www.b.com(301跳转设置) server { listen 80; server_name www.a.com; rewrite ^/(.*)$  htt ...

  6. Subversion 1.8.9 ( SVN Client ) 安装最新版本的svn客户端

    For CentOS7 Users: [WandiscoSVN] name=Wandisco SVN Repo baseurl=http://opensource.wandisco.com/cento ...

  7. mysql无法远程连接到数据库解决方法

    ERROR 1130: Host ’xxx.xxx.xxx.xxx′ is not allowed to connect to this MySQL server这是告诉你没有权限连接指定IP的主机, ...

  8. 基于TDA4863-2的单级PFC反激LED电源设计与仿真

    LED是一个非线性器件,正向电压的微小变化会引起电流的巨大变化:LED是一个半导体二极管,其伏安特性随温度变化而变化(-2mV/℃),假如温度升高,在恒压驱动下LED的电流会增加.长期超过额定电流工作 ...

  9. Ionic buid android下的此工程不是一个android项目问题

    今天编译Ionic项目的时候报如下错误,甚是费解,之前一直都是好的 首先去检查了,相关JavaHome的环境变量,确定是好的,java -version 命令没有问题. 经查阅网上的解决方法,思路大都 ...

  10. WebApi 接口返回值不困惑:返回值类型详解。IHttpActionResult、void、HttpResponseMessage、自定义类型

    首先声明,我还没有这么强大的功底,只是感觉博主写的很好,就做了一个复制,请别因为这个鄙视我,博主网址:http://www.cnblogs.com/landeanfen/p/5501487.html ...