码迷,mamicode.com
首页 > 其他好文 > 详细

UVA 10110 Light, more light【经典开灯问题】

时间:2016-08-14 16:23:30      阅读:212      评论:0      收藏:0      [点我收藏+]

标签:


Light, more light

Time Limit: 3000ms
Memory Limit: 131072KB
This problem will be judged on UVA. Original ID: 10110
64-bit integer IO format: %lld      Java class name: Main
Type:   

[PDF Link]

 
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

AC代码:

#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    int n;
    while(cin>>n,n)
    {

        int x=sqrt(n*1.0);
        if(x*x==n)
            cout<<"yes"<<endl;
        else
            cout<<"no"<<endl;
    }
    return 0;
}



UVA 10110 Light, more light【经典开灯问题】

标签:

原文地址:http://blog.csdn.net/hurmishine/article/details/52204875

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!