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. 背包九讲 附:USACO中的背包问题

    附:USACO中的背包问题 USACO是USA Computing Olympiad的简称,它组织了很多面向全球的计算机竞赛活动. USACO Trainng是一个很适合初学者的题库,我认为它的特色是 ...

  2. JSP和servlet有什么区别?

    JSP和servlet有什么区别? JSP是Servlet技术的扩展,本质上是Servlet的简易方式,更强调应用的外表表达. JSP编译后是"类servlet". Servlet ...

  3. 变形--旋转 rotate()

    旋转rotate()函数通过指定的角度参数使元素相对原点进行旋转.它主要在二维空间内进行操作,设置一个角度值,用来指定旋转的幅度.如果这个值为正值,元素相对原点中心顺时针旋转:如果这个值为负值,元素相 ...

  4. [OrangePi] If you are using an older image

    Download scriptbin_kernel.tar.gz from Mega, unpack. Copy uImage_OPI-2 or uImage_OPI-PLUS (depending ...

  5. zw版【转发·台湾nvp系列Delphi例程】Delphi 使用 HALCON库件COM控件数据格式转换

    zw版[转发·台湾nvp系列Delphi例程]Delphi 使用 HALCON库件COM控件数据格式转换 Delphi 使用 HALCON库件COM控件数据格式转换,与IHObjectX接口有关 va ...

  6. yii2开启session

    1.在写入session的页面. use yii\web\Session;$session = new Session;$session->open(); 2.在获取session的页面 use ...

  7. some software that is used to speed up your system

    1.RAMDISK take some space in ram and use them as the disk. Primo Ramdisk Server Edition 5.6.0 regist ...

  8. android 学习随笔十五(Activity的生命周期与摧毁时返回数据 )

    1.Activity的生命周期 onCreate:创建时调用 onStart:在屏幕上可见,但是还没有获得焦点 onResume:可见并且获得焦点 onPause:可见,但是失去焦点 onStop:不 ...

  9. mysql笔记01 MySQL架构与历史、Schema与数据类型优化

    MySQL架构与历史 1. MySQL架构推荐参考:http://www.cnblogs.com/baochuan/archive/2012/03/15/2397536.html 2. MySQL会解 ...

  10. linux终端快捷键

    tab 补全 ctrl+k 删除此处到末尾所有内容 ctrl+u 删除此处到开始所有内容 ctrl+a 将光标移至开始处 cttl+e 将光标移至结尾 ctrl+l 清屏 ctrl+c 删除整行或停止 ...