問題一覧 > 通常問題

No.1343 Dividing Digit

レベル : / AI推定難易度 : 475 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 183
作問者 : 8UqsVg4r / テスター : KoD blackyuki PCTprobability
お気に入りにしたユーザー ProblemId : 5768 / 自分の提出
問題文最終更新日: 2021-01-16 15:05:52
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
灘中入試コンテストday1 (順位表) の他の問題:

Problem Statement

A positive integer $A$ has $N$ digits in base-$K$ notation, and its $i$-th digit from the least significant end is $A_i$.
That is, $\displaystyle A = \sum_{i = 1}^N A_i K^{i - 1}$.
Output the remainder when $A$ is divided by $\displaystyle \sum_{i = 1}^N A_i$ (in base-$10$ notation).

Input

$N \,\, K$
$A_N \,\, A_{N-1} \,\, \ldots \,\, A_1$
  • \(1 \leq N \leq 10^5\)
  • \(2 \leq K \leq 10^4\)
  • \(0 \leq A_i < K\)
  • \(A_N \neq 0\)
  • All inputs are integers.

Output

Output the answer on a single line.

Sample

Sample 1
Input
5 2
1 0 0 1 0
Output
0

$10010_{(2)} = 18_{(10)}$, and $\displaystyle \sum_{i = 1}^N A_i = 1 + 0 + 0 + 1 + 0 = 2$.
Since $18 \equiv 0 \,\, (\bmod 2)$, output $0$.

Sample 2
Input
6 10
2 0 2 1 7 9
Output
12

In academic year \(2021\), the \(79\)th class will be joining us. How exciting!

Sample 3
Input
5 100
19 47 2 83 77
Output
33

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