結果

問題 No.1252 数字根D
ユーザー 👑 KazunKazun
提出日時 2020-08-25 00:43:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 323 bytes
コンパイル時間 147 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 72,448 KB
最終ジャッジ日時 2024-04-25 04:23:03
合計ジャッジ時間 1,869 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
51,968 KB
testcase_01 AC 35 ms
52,608 KB
testcase_02 AC 40 ms
52,480 KB
testcase_03 AC 59 ms
64,256 KB
testcase_04 AC 74 ms
71,936 KB
testcase_05 AC 71 ms
72,064 KB
testcase_06 AC 75 ms
72,064 KB
testcase_07 AC 75 ms
72,448 KB
testcase_08 AC 73 ms
72,192 KB
testcase_09 AC 72 ms
72,064 KB
testcase_10 AC 73 ms
72,064 KB
testcase_11 AC 71 ms
72,064 KB
testcase_12 AC 72 ms
71,808 KB
testcase_13 AC 72 ms
72,192 KB
testcase_14 AC 36 ms
51,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def g(N):
    if N==0:
        return 0

    if N%(D-1)==0:
        Q=N//(D-1)
        R=0
    else:
        Q=N//(D-1)+1
        R=D-1-N%(D-1)

    return Q*(D*(D-1))//2-D*R+(R*(R+1))//2

T=int(input())
X=[0]*T
for k in range(T):
    D,A,B=map(int,input().split())
    X[k]=g(B)-g(max(A-1,0))
print("\n".join(map(str,X)))
0