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. TTabControl、TMemo组件(制作一个简单的多文本编辑框)

    TTabControl包含一列字符串标签的tabs 每个标签控制一个对象 首先创建一个TForm;接下来添加TTabControl组件和一个文件对话框TOpenDialog(用于添加文件),然后在TT ...

  2. C++(VS2012)DLL动态库的生成和调用

    DLL动态链接库的生成: 首先打开VS2012,新建——项目——Win32控制台应用程序(项目名称:ConsoleApplication1)——空项目 新建一个源文件source.cpp 先用控制台e ...

  3. CentOS 7 自动更新时间日期

    # ntpdate time.nist.gov 或 # rdate -s time.nist.gov 下列服务器可用 time-nw.nist.gov

  4. Sping中的事务配置

    关于Spring的事务配置,主要的配置文件如下(使用了C3P0连接池): <?xml version="1.0" encoding="UTF-8"?> ...

  5. mysql bin log日志

    装mysql,运行一段时间后,在mysql目录下出现一堆类似mysql-bin.000***,从mysql-bin.000001开始一直排列下来,而且占用了大量硬盘空间,高达几十个G. 对于这些超大空 ...

  6. 夺命雷公狗jquery---6属性选择器

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  7. bootstrap实现 手机端滑动效果,滑动到下一页,jgestures.js插件

    bootstrap能否实现 手机端滑动效果,滑动到下一页 jgestures.js插件可以解决,只需要引入一个JS文件<script src="js/jgestures.min.js& ...

  8. Linux之sed命令详解

    简介 sed 是一种在线编辑器,它一次处理一行内容.处理时,把当前处理的行存储在临时缓冲区中,称为“模式空间”(pattern space),接着用sed命令处理缓冲区中的内容,处理完成后,把缓冲区的 ...

  9. android log机制——输出log【转】

    转自:http://blog.csdn.net/tdstds/article/details/19084327 目录(?)[-] 在android Java code中输出log Logprintln ...

  10. Redis 转

    Redis 简介 Redis实践 Redis命令总结