Switch Game

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 10200    Accepted Submission(s): 6175

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

Hint

hint

Consider the second test case:

       The initial condition : 0 0 0 0 0 …
    After the first operation : 1 1 1 1 1 …
After the second operation : 1 0 1 0 1 …
   After the third operation : 1 0 0 0 1 …
 After the fourth operation : 1 0 0 1 1 …
   After the fifth operation : 1 0 0 1 0 …
The later operations cannot change the condition of the fifth lamp any more. So the answer is 0.
 
Author
LL
 
 
转化求n个因子个数,暴力0ms过了(⊙o⊙)…
 #include<iostream>
#include<stdio.h>
#include<cstring>
#include<cstdlib>
using namespace std; int num_Euler(int n)
{
int i;
int num,ans=;
for(i=;i*i<=n;i++)
{
if(n%i==)
{
num=;
while(n%i==)
{
n=n/i;
num++;
}
ans=ans*num;
}
}
if(n!=)
ans=ans*;
return ans;
}
int main()
{
int n;
while(scanf("%d",&n)>){
int m=num_Euler(n);
printf("%d\n",(m&));
}
return ;
}
 #include<iostream>
#include<stdio.h>
#include<cstring>
#include<cstdlib>
using namespace std; bool dp[]; void init()
{
int i,j;
memset(dp,true,sizeof(dp));
for(i=;i<=;i++)
{
for(j=i;j<=;j=j+i)
if(dp[j]==true) dp[j]=false;
else dp[j]=true;
}
}
int main()
{
int n;
init();
while(scanf("%d",&n)>)
{
if(dp[n]==false)printf("0\n");
else printf("1\n");
}
return ;
}
 

hdu 2053 Switch Game 水题一枚,鉴定完毕的更多相关文章

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

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

  2. hdu 1106:排序(水题,字符串处理 + 排序)

    排序 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submissi ...

  3. HDU 4950 Monster (水题)

    Monster 题目链接: http://acm.hust.edu.cn/vjudge/contest/123554#problem/I Description Teacher Mai has a k ...

  4. HDU 4813 Hard Code 水题

    Hard Code Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.act ...

  5. HDU 4593 H - Robot 水题

    H - RobotTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.act ...

  6. HDOJ/HDU 2560 Buildings(嗯~水题)

    Problem Description We divide the HZNU Campus into N*M grids. As you can see from the picture below, ...

  7. HDOJ(HDU) 1859 最小长方形(水题、、)

    Problem Description 给定一系列2维平面点的坐标(x, y),其中x和y均为整数,要求用一个最小的长方形框将所有点框在内.长方形框的边分别平行于x和y坐标轴,点落在边上也算是被框在内 ...

  8. poj 2586 Y2K Accounting Bug(贪心算法,水题一枚)

    #include <iostream> using namespace std; /*248K 32MS*/ int main() { int s,d; while(cin>> ...

  9. PAT甲题题解-1019. General Palindromic Number (20)-又是水题一枚

    n转化为b进制的格式,问你该格式是否为回文数字(即正着写和倒着写一样)输出Yes或者No并且输出该格式又是水题... #include <iostream> #include <cs ...

随机推荐

  1. @perproty and @synthesize

    .@property 是什么? @perperty 是声明属性的语法,他可以快速方便的为实例变量创建存取器,并允许我们通过点语法使用存取器 [存取器:用于获取和设置实例变量的方法,获取实例变量值得是g ...

  2. prezi破解教程

    http://www.joenchen.com/archives/998 http://www.joenchen.com/archives/945 Prezi Desktop 4.7.5免注册无时间限 ...

  3. php4.3.4.4、apache2.0.4.8、mysql 4.0.26、window7 配置过程

    apache的安装不需要过程,直接默认安装,下一步 下一步就Ok了. php4的安装: 1 将php-4.0.4-Win32.zip(最新版本4.0.4)解压缩到硬盘的一个目录中,例如解压到E:php ...

  4. 04---Net基础加强

    字符串常用方法: 属性: Length获取字符串中字符的个数 IsNullOrEmpty()   静态方法,判断为null或者为“” ToCharArray() 将string转换为char[] To ...

  5. gulpfile.js

    文件目录如上: 下载代码地址:https://github.com/lianbinghua/gulptest 切换目录:cd gulp 安装依赖包:npm install 编译文件:gulp或者gul ...

  6. Android2.2快速入门 zz

    http://www.cnblogs.com/over140/archive/2010/09/27/1836567.html 前言 这是前段时间用于公司Android入门培训的资料,学习Android ...

  7. PAT乙级 1016. 部分A+B (15) C语言实现

    1016. 部分A+B (15) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 正整数A的“DA(为1位整数)部 ...

  8. zw版【转发·台湾nvp系列例程】HALCON EquHistoImage(Delphi)

    zw版[转发·台湾nvp系列例程]HALCON EquHistoImage(Delphi) zw版[转发·台湾nvp系列例程]HALCON EquHistoImage(Delphi) (Delphi ...

  9. 雅虎工程师提供的CSS初始化代码

    body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,button,textarea,p,b ...

  10. Yii增删改查操作

    增: 1 第一种 $post=new Post; $post->title='sample post'; $post->content='content for the sample po ...