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;}
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
hide comments
utkarsha gaumat:
2015-10-19 20:33:30
why 15409428 givin wa |
|
Phil Ronan:
2015-08-13 23:18:42
Solved it!
|
|
Daniel Carvalho:
2015-02-23 12:31:05
@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. |
|
Stanley Pham:
2015-01-07 03:53:37
I got this error when submiting, didn't get it yesterday. Can you please check?
|
|
Baojun Wang:
2014-07-20 09:35:08
could someone check why 11982715/11983011 gives wa, please?
|
|
willsw:
2013-10-18 06:30:45
may i know if operators like ++ -- << are treated as used symbol twice in the statement? Last edit: 2013-10-18 06:35:41 |
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 |