亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

Light, more light - PC110701

系統(tǒng) 2040 0

歡迎訪問我的新博客: http://www.milkcu.com/blog/

原文地址: http://www.milkcu.com/blog/archives/uva10110.html

原創(chuàng):Light, more light - PC110701

作者: MilkCu

題目描述

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

解題思路

任一整數(shù),它可能為平方數(shù)或非平方數(shù)。
若為非平方數(shù),則它的因子總是成對出現(xiàn)的,即因子個數(shù)為偶數(shù);
若為平方數(shù),則它的因子個數(shù)為奇數(shù)。
也就是說:
如果n為非平方數(shù),則燈的狀態(tài)為關(guān);
如果n為平方數(shù),則燈的狀態(tài)為開。

剛開始評測一直說是錯誤的答案,可能是因為數(shù)據(jù)類型和頭文件的問題。

代碼實現(xiàn)

    #include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main(void) {
	while(1) {
		long long n;
		cin >> n;
		if(n == 0) {
			break;
		}
		long long tmp = sqrt(n);
		if(n == tmp * tmp) {
			cout << "yes" << endl; 
		} else {
			cout << "no" << endl;
		}
	}
	return 0;
}
  

(全文完)

本文地址: http://blog.csdn.net/milkcu/article/details/23543557

Light, more light - PC110701


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯(lián)系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!??!

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 亚洲一区二区三区国产精品 | 亚洲性久久久影院 | 欧美日韩高清在线观看一区二区 | 一级毛片大全免费播放 | 综合在线亚洲 | 99久久99热久久精品免费看 | 日韩伦理视频 | 久久这里只有精品免费播放 | 一级黄色毛片播放 | 四虎sihu新版影院亚洲精品 | 久艹视频在线 | 欧美男女爱爱视频 | 中文字幕视频一区 | 国产成人精品日本 | 五月婷婷亚洲 | 国产精品久久久久999 | 涩涩伊人| 99久国产 | 狠狠狠色丁香婷婷综合久久88 | 精品国产品欧美日产在线 | 狠狠躁夜夜躁人人爽天天天天 | 欧美xvideosexo另类 | 高清在线一区二区三区亚洲综合 | 国产99久久久久久免费看 | 亚洲精品图 | 综合久久久久久久 | 婷婷热 | 女人l8毛片a一级毛片 | 亚洲一区精品视频在线 | 国产精品成人第一区 | 日本免费一区二区三区毛片 | 久草男人天堂 | 久久伊| 天天欧美 | 老外黑人欧美一级毛片 | 欧美人与zoxxxx另类9 | 日韩一区二区三 | 四虎影视在线影院4hu | 久久久99视频 | 奇米奇米色 | 91亚洲国产成人久久精品网址 |