結果

問題 No.1252 数字根D
ユーザー maspymaspy
提出日時 2020-09-01 17:13:23
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 408 bytes
コンパイル時間 90 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-04-30 00:18:16
合計ジャッジ時間 1,319 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,496 KB
testcase_01 AC 29 ms
10,496 KB
testcase_02 AC 28 ms
10,496 KB
testcase_03 AC 32 ms
10,624 KB
testcase_04 AC 38 ms
10,752 KB
testcase_05 AC 37 ms
10,624 KB
testcase_06 AC 37 ms
10,752 KB
testcase_07 AC 38 ms
10,624 KB
testcase_08 AC 37 ms
10,624 KB
testcase_09 AC 37 ms
10,496 KB
testcase_10 AC 37 ms
10,624 KB
testcase_11 AC 39 ms
10,624 KB
testcase_12 AC 37 ms
10,624 KB
testcase_13 AC 37 ms
10,624 KB
testcase_14 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def f(D, N):
    # sum_{i=1}^N
    q, r = divmod(N, D)
    x = D * (D + 1) // 2 * q
    x += r * (r + 1) // 2
    return x

T = int(readline())
for _ in range(T):
    D, A, B = map(int, readline().split())
    x = f(D - 1, B) - f(D - 1, A - 1)
    if A == B == 0:
        x = 0
    print(x)
0