Se7enProblem code: F4 |
All submissions for this problem are available.
Tomek and his numerous friends are standing in a circle. They are all numbered with consecutive identifiers, from 1 to 1337 in the clockwise direction. Starting from person 1, who says "1", successive people read out successive positive integers. The starting direction is clockwise, and there is rule, that whenever integer is divisible by 7 or contains digit 7, the direction is reversed.
So, the identifiers of the persons who read-out successive numbers, are: 1,2,3,4,5,6,7 (person 7 has just read "7" and reversed the direction),6,5,4,3,2,1,1337 (person 1337 has just read "14" and reversed the direction),1,2,3 (person 3 has just read "17" and reversed the direction),2,1,1337,1336, and so on. Tomek has his favorite number, and he wants to calculate where in the circle he should stand to read that number out loud. Even though he is skilled programmer, he is a bit little lazy and would like you to help him out.
Input
First, 1 ≤ t ≤ 1000, the number of test cases. Each test case is in a separate line, and contains a positive integer smaller than 10100, representing Tomek's favorite number.
Output
For each testcase, output one integer, the identifier which Tomek should choose in the circle to read his favorite integer loud.
Example
Input: 3 10 100 1000 Output: 4 2 1311
| Author: | admin |
| Date Added: | 10-07-2009 |
| Time Limit: | 1 sec |
| Source Limit: | 50000 Bytes |
| Languages: | ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC |
Comments

Fetching successful submissions

I am geting "Wrong Answer"
I am geting "Wrong Answer" message despite the fact, that with what ever test data I am entering, am getting the correct answer. Could the "Wrong answer" be little more specific.
Nope :)
Nope :)
If you are getting a WA, it
If you are getting a WA, it means that your code gives the wrong output for one of the test cases. :)
oh man... my prog works
oh man... my prog works perfect but its gettin timed out! sigh!
I get the correct answer for
I get the correct answer for 10, 100 and 1000. i.e. 4, 2, and 1311 respectively, on my PC.
But I am getting a "WA" in CodeChef
Should the output for 3 return nothing as in the example?
Is the output format stringent? I have left a blank line after the output.
My program compiles fine on
My program compiles fine on my compiler (JAVA) but it shows compilation error in your system.
@Akshat: Change the classname
@Akshat: Change the classname to 'Main'. The program will work then
Its already Main, still its
Its already Main, still its not accepting... :(
Configuration of my PC
Configuration of my PC :
AMD Athlon 64 X2 Dual
Core Processor 4800+
2.50 Ghz, 1.75 GB RAM
timing results on my PC shows (after running time <program name>):
real 0m5.500s
user 0m0.031s <Less than 1sec. as required>
sys 0m0.015s <Less than 1sec. as required>
Why does codechef show Time Limit Exceeded.
@Anup George The 3 in the
@akshat Take a look at
@akshat Take a look at www.codechef.com/help for more information on how to submit a problem in java.
Thamks for the help, your
Thamks for the help, your system doesn't allow system.console, the problem got sorted. but now it says wrong ans but i have tested it for quite a cases. :(
I was able to compile and
I was able to compile and run the program successfully. But when I submit the program here, it shows me compilation error.Any idea what can I do to avoid this?
Check out the FAQ at
Check out the FAQ at http://blog.codechef.com/2009/06/29/frequently-asked-questions/ and also the help section at www.codechef.com/help for a sample solution in your language.
I am also getting the
I am also getting the compilation error while it compiles perfect on my system. can you please mail the compilation error log?
solved. issue was "void
solved. issue was "void main()" instead of "int main()" - wrong prototype.
i m new to code
i m new to code chef.....
plzz tell me how to submit sol ie what exactly we have to submit
You have to submit a solution
You have to submit a solution to the problem that takes input from stdin and writes output to stdout. Your program should be in one of the supported languages mentioned. It will be run against different test cases and if it produces the right answer for all of them, then it will be judged as correct, else you will get the status as Wrong answer.
i have written a code in
i have written a code in java. it is running fine on my machine but when i upload it online(code chef) it shows run time error ???
Read the FAQ and
Read the FAQ and www.codechef.com/help
What about the no.s that
kk.. my bad.. the no. should
hi, where should i submit
hi,
where should i submit the code........
I am not able to solve it.
I am not able to solve it. But I am interested in knowing the algorithm. can somebody send the algorithm please ?