結果

問題 No.1252 数字根D
ユーザー rlangevinrlangevin
提出日時 2023-01-25 22:50:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 233 bytes
コンパイル時間 323 ms
コンパイル使用メモリ 86,836 KB
実行使用メモリ 78,368 KB
最終ジャッジ日時 2023-09-09 07:13:07
合計ジャッジ時間 2,972 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,056 KB
testcase_01 AC 77 ms
70,788 KB
testcase_02 AC 72 ms
71,064 KB
testcase_03 AC 98 ms
76,088 KB
testcase_04 AC 117 ms
78,016 KB
testcase_05 AC 117 ms
78,368 KB
testcase_06 AC 117 ms
78,080 KB
testcase_07 AC 117 ms
78,076 KB
testcase_08 AC 118 ms
78,088 KB
testcase_09 AC 123 ms
77,968 KB
testcase_10 AC 119 ms
78,072 KB
testcase_11 AC 116 ms
78,044 KB
testcase_12 AC 117 ms
77,928 KB
testcase_13 AC 116 ms
77,964 KB
testcase_14 AC 71 ms
71,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def f(a, d):
    if a <= 0:
        return 0
    q, r = divmod(a, d - 1)
    return q * d * (d - 1)//2 + r * (r + 1)//2

T = int(input())
for _ in range(T):
    d, A, B = map(int, input().split())
    print(f(B, d) - f(A - 1, d))    
0