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. salt-api安装与配置

    一,安装部分[root@LCB-U-syng01 ~]#wget https://pypi.python.org/packages/source/p/pip/pip-1.5.6.tar.gz#md5= ...

  2. PySpider HTTP 599: SSL certificate problem错误的解决方法

    在用 PySpider 爬取 https 开头的网站的时候遇到了 HTTP 599: SSL certificate problem: self signed certificate in certi ...

  3. WebSocket原理与实践(一)---基本原理

    WebSocket原理与实践(一)---基本原理 一:为什么要使用WebSocket?1. 了解现有的HTTP的架构模式:Http是客户端/服务器模式中请求-响应所用的协议,在这种模式中,客户端(一般 ...

  4. 201904Online Human Action Recognition Based on Incremental Learning of Weighted Covariance Descriptors

    论文标题:Online Human Action Recognition Based on Incremental Learning of Weighted Covariance Descriptor ...

  5. Image Restoration[Deep Image Prior]

    0.背景 这篇论文是2017年11月29号第一次提交到arxiv并紧接着30号就提交了V2版本的. 近些年DCNN模型在图像生成和修复上面表现很好,大部分人认为好的原因主要是由于网络基于大量的图片训练 ...

  6. odoo仓库单据产品过滤写法

    def onchange_picking_type_id(self, cr, uid,ids, picking_type_id, context=None): if picking_type_id i ...

  7. C# 判断一个文本文件的编码格式(转载)

    文件的字符集在Windows下有两种,一种是ANSI,一种Unicode.对于Unicode,Windows支持了它的三种编码方式,一种是小尾编码(Unicode),一种是大尾编码(BigEndian ...

  8. SQLServer 窗口函数(转载)

    一.窗口函数的作用 窗口函数是对一组值进行操作,不需要使用GROUP BY 子句对数据进行分组,还能够在同一行中同时返回基础行的列和聚合列.窗口函数,基础列和聚合列的查询都非常简单. 二.语法格式 窗 ...

  9. java json字符串传递给 js 时 特殊字符转义错误 研究

    一些换行 回车等符号需要转义 主要注意 单引号 与双引号. 一 如果js以 双引号接收字符串 则转单引号 "  至 \" 否则js报错 二 如果js以 单引号接收字符串 则转单引号 ...

  10. [Oracle]In-Memory的Join Group 位于内存的何处?

    In-Memory的Join Group 的数据字典位于内存的何处? 有客户问到,使用Oracle 的In-Memory功能时,如果用到了 Join Group,那么这些这些Join Group,位于 ...