Exit codeProblem code: ECODE |
All submissions for this problem are available.
Professor X got lost in a maze of an ancient tomb in Egypt. While he was finding the way to escape, he got a message of the tomb builders on the old walls:
- The code to open the exit door is the sequence C of n digits formed c1..cn (ci∈[0,9] ).
- For every sequence C, combining with the given integers A,B, call:
- h0=0
- hi=(hi-1×A+ci) mod B
- The smallest sequence C (in lexicological order) satisfying hn=G (where G is a given integer) is the exit code which professor X needs.
- 1≤n≤12
- 10≤A,B≤1015
- 0≤G<B
- The input satisfies that the answer always exist.
Request
Give the integers n,A,B,G, help professor X find out the exit code!Input
One and only line contains the integers n,A,B,G, respectively, each of them is separated with at least one space character.
Output
Output in a single line the exit code found.
Example
Input:3 11 111 92Output:
084
Limitations
| Author: | anhdq |
| Date Added: | 5-05-2010 |
| Time Limit: | 6 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, ERL, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TEXT, WSPC |
Comments
SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:
HELP
Program should read from standard input and write to standard output. After you submit a solution you can see your results by clicking on the [My Submissions] tab on the problem page. Below are the possible results:
- Accepted
Your program ran successfully and gave a correct answer. If there is a score for the problem, this will be displayed in parenthesis next to the checkmark. - Time Limit Exceeded
Your program was compiled successfully, but it didn't stop before time limit. Try optimizing your approach. - Wrong Answer
Your program compiled and ran succesfully but the output did not match the expected output. - Runtime Error
Your code compiled and ran but encountered an error. The most common reasons are using too much memory or dividing by zero. For the specific error codes see the help section. - Compilation Error
Your code was unable to compile. When you see this icon, click on it for more information.
If you are still having problems, see a sample solution here.

Fetching successful submissions

How much is the time limit?
How much is the time limit?
@admin what is wrong with my
@admin what is wrong with my code???
I too feel some problem , i
I too feel some problem , i am iterating over all solutions (may have TLE not wrong answer). The equation is quite simple of the form Sum( (Cx*(A^y) )%B ) , where x and y varies in a region. Sample test case answer is correct. i tried using "newline" and without newline.
It's strange. Same code is
It's strange. Same code is running on windows properly but not on linux machines :) grrr...!