国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

Switch Game

2019-11-06 06:27:49
字體:
供稿:網(wǎng)友
   There are many lamps in a line. All of them are off at first. A series of Operations are carried out on these lamps. On the i-th operation, the lamps whose numbers are the multiple of i change the condition ( on to off and off to on ). InputEach test case contains only a number n ( 0< n<= 10^5) in a line. OutputOutput the condition of the n-th lamp after infinity operations ( 0 - off, 1 - on ).Sample Input
15Sample Output
1

0

----------------------------我是滑稽的分割線------------------------------------------------------------------------

思路分析:

每個人進入都會改變燈的狀態(tài),第n個進入就會改變n的倍數(shù)的號的燈,比如第一個進所有數(shù)字都被改變,第二個進,2、4、6、8....狀態(tài)會反轉(zhuǎn)。

實質(zhì)上就是求:一個數(shù)字的因子個數(shù)。

回顧總結(jié):

該題暫未遇到坑。

#include <iostream>#include<string.h>/* run this PRogram using the console pauser or add your own getch, system("pause") or input loop */using namespace std;int lamp[100001];//求能被這個數(shù)整除的個數(shù) int main(int argc, char** argv) {int n;while(cin>>n){	int ct=0;	for(int i=1;i<=n;i++)	{		if(n%i==0)		ct++;	 } 	 if(ct%2==0)	 {	 printf("0/n");	 }	 else	 {	  printf("1/n");	 }}	return 0;}


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 杂多县| 沅江市| 杂多县| 中宁县| 肥城市| 左权县| 宜兰县| 富民县| 鄂伦春自治旗| 新竹县| 霸州市| 崇左市| 武定县| 巍山| 宁晋县| 黄大仙区| 宁蒗| 加查县| 定南县| 古交市| 德格县| 遂宁市| 涿鹿县| 芜湖市| 华容县| 平利县| 清苑县| 曲周县| 泰顺县| 盐城市| 定远县| 东光县| 儋州市| 灌南县| 喀什市| 郴州市| 南丹县| 鹤庆县| 曲水县| 纳雍县| 郴州市|