博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Switch Game
阅读量:7098 次
发布时间:2019-06-28

本文共 1299 字,大约阅读时间需要 4 分钟。

 

Problem Description
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 ).
 

 

Input
Each test case contains only a number n ( 0< n<= 10^5) in a line.
 

 

Output
Output the condition of the n-th lamp after infinity operations ( 0 - off, 1 - on ).
 

 

Sample Input
1 5
 

 

Sample Output
1 0
Hint
hint
Consider the second test case: The initial condition : 0 0 0 0 0 … After the first operation : 1 1 1 1 1 … After the second operation : 1 0 1 0 1 … After the third operation : 1 0 0 0 1 … After the fourth operation : 1 0 0 1 1 … After the fifth operation : 1 0 0 1 0 … The later operations cannot change the condition of the fifth lamp any more. So the answer is 0.
 
AC代码:
import java.util.Scanner;public class Main {    public static void main(String args[]) {        Scanner reader = new Scanner(System.in);        while (reader.hasNext()) {            int n = reader.nextInt();            double y = Math.pow(n, 1.0 / 2);            if (y % 1 == 0) {                System.out.println("1");            } else {                System.out.println("0");            }        }    }}

  

转载于:https://www.cnblogs.com/ixummer/p/8509027.html

你可能感兴趣的文章
Freemarker常用技巧(二)
查看>>
2.C#中通过委托Func消除重复代码
查看>>
[转] 基于PHP Stream Wrapper开发有趣应用场景
查看>>
JS获取屏幕大小
查看>>
hdu2222-Keywords Search 【AC自动机】
查看>>
Jsp使用HttpSessionBindingListener实现在线人数记录
查看>>
SQL中的等号、IN、LIKE三者的比较
查看>>
JSPatch 成长之路
查看>>
vuejs学习网站推荐
查看>>
如何在Fedora或CentOS上使用Samba共享
查看>>
乐视mysql面试题
查看>>
常用文件扩展名
查看>>
如何让Linux定时任务crond以秒为单位执行(如每隔3秒)
查看>>
二叉树的构造
查看>>
linux中线程池【转】
查看>>
php通过字符串生存hashCode
查看>>
SQL Server memory – Internals
查看>>
$.ajax和$.post的区别(前者根据key-value/后者根据形参)
查看>>
Node.js SDK与fabric链码交互开发
查看>>
vue - index.html
查看>>