Chef and the Dual Palindromes
All submissions for this problem are available.
Read problems statements in Mandarin Chinese and Russian as well.
A number is called a Dual Palindrome if it's representation in bases B1 and B2 are both palindromes. e.g. Let B1 = 3, B2 = 4, then number 130 (in base 10) will be called a Dual Palindrome, as it is palindrome in base 3 (11211) as well as in base 4 (2002). However, it is not a Dual Palindrome for B1 = 3 and B2 = 5 as it's not a palindrome in base 5(1010).
Given two integers B1 and B2, Chef wants to find Dual Palindromes less than 260. If there are more than 1000 Dual Palindromes, then output the first 1000 only (these numbers should be in base 10).
The fine line of the input contains an integer T denoting the number of test cases.Each test case consists of a single line containing two space separated integers: B1 and B2, respectively.
For each test case, output a list of space separated integers which are Dual Palindromes less than 260 for the input bases. If there are more than 1000 Dual Palindromes, then output the first 1000 only. The numbers should be printed in an ascending order.
- 1 ≤ T ≤ 5
- 2 ≤ B1 < B2 ≤ 16
Input: 1 2 3 Output: 1 6643 1422773 5415589 90396755477 381920985378904469
NoteSource limit for the problem is 8000B instead of usual 50000B.
|Tags||backtracking, cook61, hard, maths, rustinpiece|
|Time Limit:||8 sec|
|Source Limit:||8000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions