THINKX - Strange Pattern (Hard)

Mr. X has mastered programming. Fibonacci is too easy for him. To make his name heard all over the world, he challenges you to create a function that returns 2 if the input is 1, and returns 3 if the input is greater than 1.

Since Mr. X wants to make himself famous, the function must be simple and some advertising must be put in the function. He only wants you to do a single statement in the function so it's easy to read. The statement must also not contain any numbers or letters other than 'x'. To make it more interesting, every operator or symbol other than x can only be used once in the statement.

Mr. X has given you his code for you to edit, but you can only edit a certain part of the code.

#include <stdio.h>

int count(int x){

return edit this part;

}

int main(){for(int i=1;i<100001;i++)printf("%d %d\n",i,count(i));return 0;}

#include <stdio.h>
int count(int x){
return (x+1)%x+2
}
int main(){
for( int i=1 ; i-1001 ; i++ ) printf("%d %d\n",i,count(i));
return 0;
}M

Mr. X will first check the correctness of the output. If the output is correct, he then will check the code. If there is anything that violates the rule above, the result will be "compilation error". Changing the code other than the allowed part may also result in a compile error.

DO NOT USE ANY WHITESPACE ON THE EDITED PART

Input

No input.

Output

1 2
2 3
3 3
4 3
... and so on ...
99998 3
99999 3
100000 3 

Click here to see all problems in this series!


Added by:Andy
Date:2013-05-25
Time limit:1s
Source limit:250B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:C++ 4.3.2
Resource:own problem

hide comments
2015-10-19 20:33:30 utkarsha gaumat
why 15409428 givin wa
2015-08-13 23:18:42 Phil Ronan
Solved it!

Just for reference, it looks like double operators (&&, ++, etc.) are *not* allowed.
2015-02-23 12:31:05 Daniel Carvalho
@Andy, could you check why the submission 13716494 is incorrect? The only reason I can think of is that I used an operator 2 characters long, both equal, and thus repeated a symbol.
2015-01-07 03:53:37 Stanley Pham
I got this error when submiting, didn't get it yesterday. Can you please check?
"Error
Language available only on Cube Cluster "
2014-07-20 09:35:08 Baojun Wang
could someone check why 11982715/11983011 gives wa, please?

Ans(Andy): they output all zeros and all twos

Last edit: 2014-08-01 06:18:22
2013-10-18 06:30:45 willsw
may i know if operators like ++ -- << are treated as used symbol twice in the statement?

Last edit: 2013-10-18 06:35:41
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.