我需要在java编程中回答这个问题吗? [英] I need a answer on that question in java programming?

查看:55
本文介绍了我需要在java编程中回答这个问题吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Snapper是一个聪明的小设备,一方面将其输入插头插入输出插座,另一方面,暴露出一个输出插座,用于插入灯或其他设备。

当Snapper处于ON状态并从其输入插头接收电源时,连接到其输出插座的设备也会接收电源。当你用手指敲击时

- 发出咔哒声

- 任何Snapper在瞬间接通电源时会在ON和OFF状态之间切换。

为了通过奇点破坏宇宙,我购买了N Snapper设备并将第一个连接到一个电源插座,第二个连接到第一个,所以上。灯插入Nth Snapper。

最初,所有Snapper都处于OFF状态,因此只有第一个从插座接收电源,并且指示灯熄灭。我用手指敲了一下,将第一个Snapper切换到ON状态,然后给第二个Snapper供电。我再次抓住我的手指,切断两个Snappers,然后立即从第二个切断电源,使其处于ON状态,但没有电源。我第三次抓住我的手指,再次拨动第一个鲷鱼并为第二个狙击手供电。现在两个Snapper都处于ON状态,如果我的灯插入第二个Snapper,它将会打开。

我这么做几个小时。我用手指拍K次后会打开还是关闭灯?当且仅当它从插入的鲷鱼接收电源时,指示灯亮起。

输入

输入的第一行给出了测试用例的数量,T T行如下。每个包含两个整数,N和K.

输出

对于每个测试用例,输出一行包含Case #x:y,其中x是案例编号(从1开始),y为ON或OFF,表示灯泡的状态

The Snapper is a clever little device that, on one side, plugs its input plug into an output socket, and, on the other side, exposes an output socket for plugging in a light or other device.
When a Snapper is in the ON state and is receiving power from its input plug, then the device connected to its output socket is receiving power as well. When you snap your fingers
-- making a clicking sound
-- any Snapper receiving power at the time of the snap toggles between the ON and OFF states.
In hopes of destroying the universe by means of a singularity, I have purchased N Snapper devices and chained them together by plugging the first one into a power socket, the second one into the first one, and so on. The light is plugged into the Nth Snapper.
Initially, all the Snappers are in the OFF state, so only the first one is receiving power from the socket, and the light is off. I snap my fingers once, which toggles the first Snapper into the ON state and gives power to the second one. I snap my fingers again, which toggles both Snappers and then promptly cuts power off from the second one, leaving it in the ON state, but with no power. I snap my fingers the third time, which toggles the first Snapper again and gives power to the second one. Now both Snappers are in the ON state, and if my light is plugged into the second Snapper it will be on.
I keep doing this for hours. Will the light be on or off after I have snapped my fingers K times? The light is on if and only if it's receiving power from the Snapper it's plugged into.
Input
The first line of the input gives the number of test cases, T. T lines follow. Each one contains two integers, N and K.
Output
For each test case, output one line containing "Case #x: y", where x is the case number (starting from 1) and y is either "ON" or "OFF", indicating the state of the light bulb

Limits
1 <= T <= 1000.
1 <= N <= 10
0 <= K <= 100

Sample

Input 
  	
                 Output 
  
4
1 0
1 1
4 0
4 47	         Case #1: OFF
         Case #2: ON
         Case #3: OFF
         Case #4: ON

推荐答案

对不起,这个不是一个有效的问题。我们不做你的工作,无论是商业还是学术。写这个程序的目的是测试你的技能和知识,而不是那些陌生人。
Sorry, this is not a valid question. We do not do your work, whether commercial or academic. Writing this program is designed to test your skills and knowledge not those of some strangers.


我的朋友,



这是你的作业问题?

你应该做数学来弄清楚这个概念,它几乎没有任何数学但只是一点点逻辑。我会鼓励你拿一张纸和一支笔。在笔记本上进行少量测试并根据这些结果,你必须找出一个逻辑。然后将该逻辑制成流程图或伪代码,并且伪代码在任何给定语言的实际语法中转换。这就是我亲爱的朋友的工作方式。



目前,除非你告诉我你尝试了什么,否则我不会给你任何暗示我帮你。顺便说一句,我已经给你指示回来并开始工作。



有问候

Tushar Srivastava
My Friend,

Is this your homework question?
You should have to do the maths to figure out the concept and it's barely any maths but just a little logic. I will encourage you to take a paper and a pen. Do the few tests on notebook and based on those results, you have to figure out a logic. Then that logic is made into a flowchart or pseudo code and that pseudo code is converted in real syntax of any given language. This is how it works my dear friend.

For the moment being, I will not be giving you any hint unless you show me what have you tried and then only will I help you. BTW, I have given you the pointers to get back and start working.

With Regards
Tushar Srivastava

这篇关于我需要在java编程中回答这个问题吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆