博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
杭电2053
阅读量:7176 次
发布时间:2019-06-29

本文共 814 字,大约阅读时间需要 2 分钟。

Re:题意:有无限多的电灯排成一列,一开始都是关,操作无限多次,第i次操作会把编号为i和i的倍数的电灯改变状态。问最后第i盏电灯的状态是开还是关    //后边有数据。。。
#include
int main(){
int a,b,i; while(scanf("%d",&a)!=EOF) {
b=0; for(i=1;i<=a;i++) {
if(a%i==0) b++; } if(b%2==1)//开关变化(1 0 1 0 1 0.......); printf("1\n"); else printf("0\n"); } return 0;}
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.

 

转载于:https://www.cnblogs.com/soTired/p/4415128.html

你可能感兴趣的文章
GetVersion和GetVersionEx
查看>>
php采集利器snoopy应用技巧
查看>>
我的友情链接
查看>>
安装虚拟机shell脚本
查看>>
[Python]第一个爬虫练习
查看>>
rpm,yum,权限
查看>>
tomcat应用转到weblogic上时的问题
查看>>
vSphere 5.5 vCenter迁移至分布式交换机
查看>>
第二次作业
查看>>
viewport ——视区概念
查看>>
拓扑规则翻译函数(转)
查看>>
数据结构--图的定义和存储结构
查看>>
linux常用命令
查看>>
Appium自动化测试1 - 安装部署
查看>>
Bzoj 1648: [Usaco2006 Dec]Cow Picnic 奶牛野餐 深搜,bitset
查看>>
UVa294 Divisors
查看>>
洛谷P3406 海底高铁
查看>>
1、JUC--volatile 关键字-内存可见性
查看>>
uboot arp地址解析
查看>>
Java字节码 小结
查看>>