結果

問題 No.1252 数字根D
ユーザー 👑 KazunKazun
提出日時 2020-08-25 03:23:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 438 bytes
コンパイル時間 209 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 71,808 KB
最終ジャッジ日時 2024-04-25 04:23:47
合計ジャッジ時間 1,937 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
52,352 KB
testcase_01 AC 42 ms
52,224 KB
testcase_02 AC 44 ms
52,480 KB
testcase_03 AC 67 ms
64,000 KB
testcase_04 AC 82 ms
71,296 KB
testcase_05 AC 82 ms
71,424 KB
testcase_06 AC 83 ms
71,552 KB
testcase_07 AC 82 ms
71,808 KB
testcase_08 AC 81 ms
71,296 KB
testcase_09 AC 83 ms
71,552 KB
testcase_10 AC 85 ms
71,296 KB
testcase_11 AC 82 ms
71,424 KB
testcase_12 AC 82 ms
71,424 KB
testcase_13 AC 82 ms
71,680 KB
testcase_14 AC 40 ms
51,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def g(N):
    Q,R=divmod(N,D-1)
    return Q*(D*(D-1))//2+(R*(R+1))//2

T=int(input())
assert 1<=T<=2000,"Tが範囲外(T={})".format(T)

X=[0]*T
for k in range(T):
    D,A,B=map(int,input().split())
    assert 2<=D<=10**9,"(第{}テストケース)Dが範囲外(D={})".format(k+1,D)
    assert 0<=A<=B<=10**9,"(第{}テストケース)A,Bが範囲外(A={},B={})".format(k+1,A,B)

    X[k]=g(B)-g(max(A-1,0))
print("\n".join(map(str,X)))
0