开始所有的灯是灭的,不过我们只关心最后一个灯。

在第i次走动时,只有编号为i的倍数的灯的状态才会改变。

也就是说n有偶数个约数的时候,最后一个灯的状态不会改变,也就是灭的。

n有奇数个约数的时候也就是n为完全平方数的时候,最后一个灯会是亮的。

最后抽象出来,就是判断输入的数是否为完全平方数。

Light, more light

The Problem

There is man named "mabu" for switching on-off light in our University. He switches on-off the lights in a corridor. Every bulb has its own toggle switch. That is, if it is pressed then the bulb turns on. Another press will turn it off. To save power consumption (or may be he is mad or something else) he does a peculiar thing. If in a corridor there is `n' bulbs, he walks along the corridor back and forth `n' times and in i'th walk he toggles only the switches whose serial is divisable by i. He does not press any switch when coming back to his initial position. A i'th walk is defined as going down the corridor (while doing the peculiar thing) and coming back again.

Now you have to determine what is the final condition of the last bulb. Is it on or off?

The Input

The input will be an integer indicating the n'th bulb in a corridor. Which is less then or equals 2^32-1. A zero indicates the end of input. You should not process this input.

The Output

Output "yes" if the light is on otherwise "no" , in a single line.

Sample Input

3
6241
8191
0

Sample Output

no
yes
no

Sadi Khan 
Suman Mahbub 
01-04-2001

AC代码:

 //#define LOCAL
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std; int main(void)
{
#ifdef LOCAL
freopen("10110in.txt", "r", stdin);
#endif unsigned int N;
while(scanf("%d", &N) == && N)
{
int n = (int)sqrt(N);
if(n * n == N)
cout << "yes" << endl;
else
cout << "no" << endl;
}
return ;
}

代码君

UVa 10110 Light, more light的更多相关文章

  1. Light, more light - PC110701

    欢迎访问我的新博客:http://www.milkcu.com/blog/ 原文地址:http://www.milkcu.com/blog/archives/uva10110.html 原创:Ligh ...

  2. LED Holiday Light -holiday Light Inspection Implementation Recommendations

    China LED Holiday Light Factory & Ninghai County Haohua Electronic Appliance Co., Ltd. pointed o ...

  3. C#Light 和 uLua的对比第二弹

    上次的对比大家还有印象否,C#Light和ulua对比各有胜负 今天我们加入一个去反射优化,这是uLua没办法实现的优化,我们也就只能不要脸的胜之不武了 以原生执行同一测试时间为X1,数字越小的越快 ...

  4. How to Pronounce the Idiom: ‘Out Like a Light’

    How to Pronounce the Idiom: ‘Out Like a Light’ Share Tweet Share Tagged With: Idioms English is full ...

  5. Ambient Light

    [Ambient Light] Ambient light is light that is present all around the scene and doesn’t come from an ...

  6. 精确光源(Punctual Light Sources)

    <Physically-Based Shading Models in Film and Game Production>(SIGGRAPH 2010 Course Notes) (地址: ...

  7. Unity Lighting - Light Types 灯光类型(八)

      Light Types 灯光类型 We have now covered some of the project settings which need to be considered befo ...

  8. 嵊州D3T3 light

    嵊州D3T3 light 光恰似水 兄弟俩曾经 k 次受到过父母的物质激励. 一开始,兄弟俩的能力值为 1,最后,兄弟俩的能力值是 1 + (2 ^k−1)/ n . 当兄弟俩受到价值为 mi 的物质 ...

  9. [币严区块链]ETH搭建节点区块数据同步的三种模式:full、fast、light

    ETH  全节点Archive(归档)模式数据量增长图 上述图表可通过链接查看:https://etherscan.io/chartsync/chainarchive 通过上表,可以看到截止2019年 ...

随机推荐

  1. HandlerMapping执行过程。。。

    1.web.xml DispatcherServlet 类 寻址 doDispatch() 2.getHandler(requset) 点击,进入 3.HandlerMapping hm=xxxxxx ...

  2. Java语法基础(2)

    一.变量与常量 1.标识符与关键字 (1). 标识符 标识符可以简单的理解为一个名字,用来标识类名.变量名.方法名.数组名.文件名的有效字符序列.如图所示. Java语言规定标识符由任意顺序的字母.下 ...

  3. java es 骤合操作

    ElasticSearch java API - 聚合查询 以球员信息为例,player索引的player type包含5个字段,姓名,年龄,薪水,球队,场上位置.index的mapping为: &q ...

  4. Class 学习 (Es6阮一峰)

    es5 构造函数 实例: function Point(x, y) { this.x = x; this.y = y; } Point.prototype.toString = function () ...

  5. mysql操作封装

    <?php//连接数据库function connect(){  $link = mysql_connect(DB_HOST,DB_USER,DB_PWD)or die("数据库连接失 ...

  6. (笔记)快速入门PADS logic 到 layout

    以前从未接触过画板,先是硬着头皮边学边操作<Layout2007中文教程之PADS_Logic>,刚好在中秋节前把这个教程从头到尾通学了一遍,随后感觉这个教程有了方方面面但没有工程的系统性 ...

  7. 解决首次在eclipse中使用maven构建hadoop等项目时报Missing artifact sun.jdk:tools:jar:1.5.0的问题

    问题原因: eclipse中的maven插件默认没有引用环境变量,所以找不到jdk的路径,也就找不到tool.jar. 解决办法: 步骤如下: 1.关闭eclips 2.在eclipse的解压目录中与 ...

  8. SQL Server 2017的Linked Server配置触发的bug“Exception Code = c0000005 EXCEPTION_ACCESS_VIOLATION”

    SQL Server 2017的Linked Server配置触发的bug"Exception Code    = c0000005 EXCEPTION_ACCESS_VIOLATION&q ...

  9. mysql-单表操作

    mySql单表操作主要有一下内容: 1.查询:查询又分为几种,范围查询,模糊查询.空值查询.多条件查询 查询的语句格式为:SELECT 字段 1,字段 2,字段 3...FROM 表名 WHERE 条 ...

  10. LeetCode Happy Number 开心数字

    题意: 给出一个整数n,判断其是否为幸运数. 规则是,将n按十进制逐位拆出来后,每个位各自进行取平方,再将这些平方数求和作为新的数字n.若最后n=1,就是幸运数. 思路: 计算例子:n=47,接着n= ...