EXPECT - Life, the Universe, and Everything (Interactive)

no tags 

Note for Interactive problem setters: if you are stucked on how to write a interactive problem judge, you may send a mail to "blue.mary.me@qq.com". It will send you the custom judge of this problem.

Your program is to use the brute-force approach in order to find the Answer to Life, the Universe, and Everything. More precisely... rewrite small numbers from input to output. Stop processing input after reading in the number 42. All numbers at input are integers of one or two digits.

Interactive Protocol

You should communicate with Judge using standard input and output.

Attention: the program should clear the output buffer after printing each line.

It can be done using fflush(stdout) command or by setting the proper type of buffering at the beginning of the execution - setlinebuf(stdout).

Each time the judge will give you a number. You should rewrite this number to standard output. If this number equals 42, after rewriting your program should terminate immediately.

Example

The example of communication.

Input:
3
15
42

Output:
3
15
42

Attention: the program should clear the output buffer after printing each line.

Reference

Please pay attention that: your program should NOT output any extra characters like "J","P" or “:". Follow the interactive protocol strictly. A sample program (in C++) that can get Accepted is as the following:


hide comments
elizabeth9908: 2019-11-06 08:46:08

I wrote my code in Visual Studio and it worked (gave the output that it wanted)… is there a specific solution??? Like do I need a user's input or just use an array that's already initialized with values.

pradeep_2001: 2019-11-03 12:44:33

Success in IDEONE but time limit on SPOJ. Why?

devil_luc9980: 2019-10-02 09:10:46

This problem is just not accepting any solution.Why?

amartyaa: 2019-09-25 19:46:30

program is running perfectly in idoneit and other ide's but its giving "time limit exceding" error here... WHY?

amit_625: 2019-09-20 07:33:20

Easy one, Read the question carefully, after printing the output you should flush the buffer(https://support.microsoft.com/en-in/help/94227/how-to-flush-the-cout-buffer-in-visual-c)

hasindu10: 2019-06-07 19:37:14

isn't the use of fflush is little bit too much for the newbies?

poula: 2019-06-03 10:26:07

how many elements should i take in array

capo06: 2019-05-02 19:46:48

why time limit is exceeding

faisaltrate: 2019-04-18 14:15:08

why time limit exceeding????please tell me

amuzak: 2019-03-31 15:13:41

I just solved this question on java (eclipse) and it is giving a perfect output, so why does this website say it is wrong? What am I doing wrong here? Can anyone help?


Added by:Fudan University Problem Setters
Date:2008-05-24
Time limit:10s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: C99 ERL GOSU JS-RHINO NODEJS PERL6 VB.NET
Resource:A sample of Interactive problems