若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。


  • 运维

  • 前端

  • 编程

  • 随笔

  • hust-oj

1542: Light, more light

发表于 2017-10-06   |   分类于 HUSTOJ   |   阅读次数 1,117

题目描述

There is man named Mabu who switches on-off the lights along a corridor at our university. Every bulb has its own toggle switch that changes the state of the light. If the light is off, pressing the switch turns it on. Pressing it again will turn it off. Initially each bulb is off.

He does a peculiar thing. If there are n bulbs in a corridor, he walks along the corridor back and forth n times. On the ith walk, he toggles only the switches whose position is divisible by i. He does not press any switch when coming back to his initial position. The ith walk is defined as going down the corridor (doing his peculiar thing) and coming back again. Determine the final state of the last bulb. Is it on or off?

输入

The input will be an integer indicating the nth bulb in a corridor, which is less than or equal to 232 – 1. A zero indicates the end of input and should not be processed.

输出

Output “yes'' or “no'' to indicate if the light is on, with each case appearing on its own line.

样例输入

3
6241
8191
0


样例输出

no
yes
no

参考代码

#include"stdio.h"
#include"math.h"
int main() 
{
    long n;
    while(scanf("%ld",&n)&&n) 
    {
        int x=sqrt(n);
        if(x*x==n)
                    printf("yesn");
        else
            printf("non");
    }
    return 0;
}

解析

暂无

hustoj

发表评论 取消回复

邮箱地址不会被公开。 必填项已用*标注

*
*


hoxis wechat
著作权归作者所有
站点更新说明
  • 文章目录
  • 站点概览
若是凉夜已成梦

若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。

1904 日志
6 分类
12 标签
RSS
weibo github twitter facebook

友情链接

Dreams孤独患者 原站点 Skip
© 2017 若是凉夜已成梦
Powered by WordPress | 已运行
Theme By NexT.Mist