結果

問題 No.1252 数字根D
ユーザー tanon710tanon710
提出日時 2020-10-15 22:20:20
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 386 bytes
コンパイル時間 1,703 ms
コンパイル使用メモリ 86,116 KB
実行使用メモリ 78,164 KB
最終ジャッジ日時 2023-09-28 01:25:43
合計ジャッジ時間 4,294 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
71,060 KB
testcase_01 AC 65 ms
71,020 KB
testcase_02 AC 66 ms
71,092 KB
testcase_03 AC 85 ms
76,204 KB
testcase_04 AC 103 ms
78,132 KB
testcase_05 AC 101 ms
77,960 KB
testcase_06 AC 104 ms
77,940 KB
testcase_07 AC 106 ms
78,024 KB
testcase_08 AC 104 ms
78,164 KB
testcase_09 AC 106 ms
77,932 KB
testcase_10 AC 104 ms
78,000 KB
testcase_11 AC 101 ms
77,944 KB
testcase_12 AC 105 ms
78,012 KB
testcase_13 AC 102 ms
78,008 KB
testcase_14 WA -
権限があれば一括ダウンロードができます

ソースコード

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)
    else:
        ans=calc(b)-calc(a-1)
    print(ans)
0