結果

問題 No.1252 数字根D
ユーザー tanon710tanon710
提出日時 2020-10-15 22:21:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 109 ms / 2,000 ms
コード長 394 bytes
コンパイル時間 323 ms
コンパイル使用メモリ 86,616 KB
実行使用メモリ 78,288 KB
最終ジャッジ日時 2023-09-28 01:25:45
合計ジャッジ時間 2,525 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
71,332 KB
testcase_01 AC 65 ms
71,332 KB
testcase_02 AC 65 ms
71,104 KB
testcase_03 AC 87 ms
75,924 KB
testcase_04 AC 108 ms
78,136 KB
testcase_05 AC 109 ms
77,904 KB
testcase_06 AC 106 ms
78,288 KB
testcase_07 AC 104 ms
78,116 KB
testcase_08 AC 103 ms
78,096 KB
testcase_09 AC 103 ms
77,936 KB
testcase_10 AC 108 ms
77,904 KB
testcase_11 AC 104 ms
78,020 KB
testcase_12 AC 105 ms
78,020 KB
testcase_13 AC 106 ms
77,940 KB
testcase_14 AC 64 ms
71,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

t=int(input())
for _ in range(t):
    d,a,b=map(int,input().split())
    
    def calc(n):
        if n==0:
            return 1
        else:
            block=(n-1)//(d-1)
            k=n%(d-1)
            if k==0:
                k=d-1
            return 1+(block*((d-1)*d))//2+(k*(k+1))//2
    
    if a==0:
        ans=calc(b)-calc(a)
    else:
        ans=calc(b)-calc(a-1)
    print(ans)
0