問題一覧 > 通常問題

No.3535 $E\times - Otogibanashi$

レベル : / AI推定難易度 : 950 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 1024 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 70
作問者 : nauclhlt / テスター : gomaazarasi
お気に入りにしたユーザー ProblemId : 13252 / 自分の提出
問題文最終更新日: 2026-05-08 21:28:31
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 499 (順位表) の他の問題:

Problem Statement

A positive integer satisfying the following condition is called an Otogibanashi number.

  • In its $10$-based decimal notation (without extra leading $0$), it has $6$ digits, and, writing $d_i$ for the digit in the $10^i$ place, all of $d_5=d_4, d_3=d_0, d_2=d_1$ hold

For example, 112332 and 555555 are Otogibanashi numbers, but 110101 and 120 are not Otogibanashi numbers.

Furthermore, an integer satisfying the following condition is called an Ex Otogibanashi number.

  • There exist an Otogibanashi number $k$ and a positive integer $E$ such that it can be expressed as $E\times (-k)$

You are given a positive integer $N$ and a prime $P$. Find the sum of all Ex Otogibanashi numbers whose absolute value is at most $N$, modulo $P$, as a value at least $0$ and less than $P$.

Input

$N\ P$
  • $1\leq N\leq 10^9$
  • $10^8\leq P< 10^9$
  • $P$ is prime
  • All inputs are integers

Output

Print on one line the sum of all Ex Otogibanashi numbers whose absolute value is at most $N$, modulo $P$.

Print a newline at the end.

Sample

Sample 1
Input
1729 998244353
Output
0

There are no Ex Otogibanashi numbers whose absolute value is at most $1729$. The sum is therefore $0$ as well, so print 0.

Sample 2
Input
998244353 998244353
Output
910462579

Note that you must print the remainder when divided by the prime $P$.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。