Skip to content

Instantly share code, notes, and snippets.

@Mahedi-61
Last active April 8, 2018 02:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Mahedi-61/9d8adbc482c345808e69caf3449250a4 to your computer and use it in GitHub Desktop.
Save Mahedi-61/9d8adbc482c345808e69caf3449250a4 to your computer and use it in GitHub Desktop.
/my solution to problem http://codeforces.com/problemset/problem/897/B in python
num_digit = 0
num_palindrome = 0
count = 0
n = 0
palindrome = 0
mod = 0
arr_sum = 0
s = input()
num_palindrome, mod = map(int, s.split())
while(num_palindrome > count):
count += 1
remainder = 0
rev_num = 0
num_digit = 0
n = count;
while(n != 0):
n = n // 10
num_digit += 1
n = count
while(n != 0):
remainder = n % 10
rev_num = rev_num * 10 + remainder
n = n // 10
palindrome = count * (10 ** num_digit) + rev_num
#print(palindrome)
#print(" count: ", count)
arr_sum +=palindrome
#end of while loop
print((arr_sum % mod))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment