結果
問題 |
No.1252 数字根D
|
ユーザー |
|
提出日時 | 2020-10-09 23:07:23 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 559 bytes |
コンパイル時間 | 81 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-07-20 14:01:52 |
合計ジャッジ時間 | 1,395 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | WA * 14 |
ソースコード
t = int(input()) def digit_sum(x, d): while x >= d: tmp = 0 while x > 0: tmp += x % d x //= d x = tmp return x for _ in range(t): d, a, b = map(int, input().split()) left = digit_sum(a, d) right = digit_sum(b, d) one_cycle = (d - 1) * d // 2 cycle_len = d - 1 n = b - a + 1 ds = digit_sum(a, d) ans = n // cycle_len * one_cycle head = (one_cycle - (left - 1) * left // 2) % one_cycle tail = right * (right + 1) // 2 % one_cycle print(ans + head + tail)