# Project Euler #36: Double-base palindromes

# Project Euler #36: Double-base palindromes

anshumanc007 + 0 comments for test case 1 , use unsigned long long int instead of long long int to store the number in base k...because 10^6 in binary will have around 20 digits and long long int causes overflow.

bharatkverma + 1 comment whats the problem with test case no 1.. i m not able to pass it.. what should i do.??

nemrud_demir + 0 comments Converting the number to base k takes probably too much time... Try to convert it only if it is necessary

aatreyasinha + 0 comments Recursion greatly helps to find the base. And also does not take much time. The last case came in 2 secs, in python 3.

Kuriocity + 0 comments **Hope it Helps!Simple JAVA Solution***passes all test cases*!!!import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { Scanner s=new Scanner(System.in); int n=s.nextInt(); int k=s.nextInt(); int sum=0; for(int i=1;i<n;i++) { if(new StringBuilder(i+"").reverse().toString().equals(i+"") && Integer.toString(i,k).equals(new StringBuilder(Integer.toString(i,k)).reverse().toString())) { sum+=i; } } System.out.println(sum); } }

tushartyagi8750 + 0 comments all test cases passed in less than 0.03 s in python 3

arslanburak + 0 comments How can i saw the input of the other test cases ? is it possible ?

muneersyed156 + 0 comments I am getting runtime error in testcase 14 and all the remaining got passed could any one tell me what could be the error .My code is in Python3

kitchent + 0 comments For those who are curious, my solution takes the following points into account:

- Use combinations and permutations to generate palindromes in decimal base.
- Consider when the number of digits is odd.
- Quit as soon as possible if a number is not palindrome, instead of comparing the whole string.
- Think about the relationship between the base
`K`

and the first digit (or the last digit as well).`0`

is not possible for any base.`2`

is not possible for binary,`8`

is not possible for octal...etc.

That way I could pass any test case up to N=10^10.

rambarsainya + 3 comments All test cases passed but I am getting 1.54s time taken on 5th testcase, which is highest amongs all testcases. Can i consider my algorithm efficient or do I need to optimize it further ??

nemrud_demir + 0 comments 0.25s for 5th testcase here...

heroesdavid8 + 1 comment 0.2s in python 3 here lol

heroesdavid8 + 0 comments brute forced it too

Sort 13 Discussions, By:

Please Login in order to post a comment