MBIPALIN - Bipalindrome

Pero and Slavko are two students who love math. Pero is very creative and often comes up with new ideas. Slavko later spends days thinking about Pero's ideas. One day Pero and Slavko learned what a palindrome was: a string read the same in either direction (for example, "ANA", "1991" and "RADAR" are palindromes). Later that day Pero came up with a new concept – a bipalindrome (bipalin for short).

A bipalin is a number, composed of two palindromes of the same length. Both of these palindromes are strings of decimal digits, the first which may not start with the digit 0 (therefore, the entire bipalin may not start with a 0). For example, 393020 is a bipalin (composed of the palindromes 393 and 020), while 222 and 010202 are not.

After hearing about bipalins, Slavko started thinking. After half an hour he found that there is only one bipalin of length 6 that is divisible by 12345. This is the bipalin 555525. Shocked by this finding, he wants you to write a program that, given two integers N and M, calculates the number of different bipalins of length N that are divisible by M.

Input

Input consists of two integers N and M (2 ≤ N ≤ 20, 1 ≤ M ≤ 1 000 000), where N is even.

Output

Output the number of different bipalins of length N that are divisible by M.

Sample

Input:
6 123

Output:
71
Input:
2 10

Output:
9
Input:
6 12345

Output:
1


Được gửi lên bởi:psetter
Ngày:2009-03-04
Thời gian chạy:1s
Giới hạn mã nguồn:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Ngôn ngữ cho phép:Tất cả ngoại trừ: ERL GOSU JS-RHINO NODEJS PERL6 PYPY RUST SED VB.NET
Nguồn bài:COI 08

hide comments
2021-05-18 17:51:43


Last edit: 2021-05-18 17:54:13
2015-09-08 14:12:05
https://thewizard6296.wordpress.com/2015/09/04/5/
2014-11-10 09:58:30 Lollipop
phân tập
2014-07-08 10:59:30 Phạm Thanh Hùng
Các số 10, 20, 30 , .. 90 chia hết cho 10 và là bipalin
2014-07-07 03:07:05 Thủ khoa vãn
2 10 sao lai ra 9 vay
lam gi co so nao chia het cho 10 la bipalin dau
2011-10-28 13:04:55 Noyethug
đệ quy
2010-01-13 09:01:12 ngừng code
bai nay wa hay
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.