結果

問題 No.1252 数字根D
ユーザー brthyyjpbrthyyjp
提出日時 2020-10-10 15:06:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 270 bytes
コンパイル時間 321 ms
コンパイル使用メモリ 87,192 KB
実行使用メモリ 78,524 KB
最終ジャッジ日時 2023-09-27 21:28:18
合計ジャッジ時間 2,735 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,256 KB
testcase_01 AC 66 ms
71,348 KB
testcase_02 AC 71 ms
71,580 KB
testcase_03 AC 91 ms
76,732 KB
testcase_04 AC 109 ms
78,052 KB
testcase_05 AC 106 ms
78,480 KB
testcase_06 AC 107 ms
78,440 KB
testcase_07 AC 106 ms
78,192 KB
testcase_08 AC 110 ms
78,184 KB
testcase_09 AC 107 ms
78,316 KB
testcase_10 AC 108 ms
78,304 KB
testcase_11 AC 109 ms
78,524 KB
testcase_12 AC 106 ms
78,348 KB
testcase_13 AC 107 ms
78,060 KB
testcase_14 AC 66 ms
71,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

t = int(input())

def func(x, d):
    q, r = divmod(x, d-1)
    ans = q*(d-1)*d//2
    ans += r*(r+1)//2
    return ans

for _ in range(t):
    d, a, b = map(int, input().split())
    if a != 0:
        print(func(b, d)-func(a-1, d))
    else:
        print(func(b, d))
0