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

Light, more light - PC110701

系統 2366 0

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

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

原創: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

解題思路

任一整數,它可能為平方數或非平方數。
若為非平方數,則它的因子總是成對出現的,即因子個數為偶數;
若為平方數,則它的因子個數為奇數。
也就是說:
如果n為非平方數,則燈的狀態為關;
如果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


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

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

【本文對您有幫助就好】

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

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 色酷综合 | 最新中文字幕一区 | 嫩草成人国产精品 | 久久综久久美利坚合众国 | 久久久国产一区二区三区 | 欧美日比视频 | julia在线播放 | 日韩成人精品视频 | 国产a一级毛片午夜剧场14 | 欧美精品成人免费视频 | 操操操网站 | 日韩美在线| 国产一区在线视频观看 | 久久久久久久综合色一本 | 综合色久 | 久久香蕉国产线看观看精品蕉 | 日本一本在线观看 | 奇米青青草 | 久久99精品视免费看 | 精品欧美一区二区三区在线 | 亚洲国产精品综合欧美 | 91www成人久久 | 4hu四虎永久网址 | 94在线| 欧美成人精品一级高清片 | 亚欧成人一区二区 | 精品中文字幕一区二区三区四区 | 久色免费视频 | 国产精品久久久久影视青草 | 久久香蕉综合色一综合色88 | 免费久草 | 91在线视频免费播放 | jizzjizzjizz孕妇| 欧美久在线观看在线观看 | 天天狠狠色噜噜 | 成人国产在线不卡视频 | 手机看片福利日韩欧美看片 | 奇米999| 91尤物国产尤物福利 | 色综合久久亚洲国产日韩 | 99久久精品久久久久久清纯 |