結果

問題 No.1252 数字根D
ユーザー tamatotamato
提出日時 2020-10-09 21:49:10
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 663 bytes
コンパイル時間 323 ms
コンパイル使用メモリ 87,468 KB
実行使用メモリ 77,328 KB
最終ジャッジ日時 2023-09-27 16:19:41
合計ジャッジ時間 2,500 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,620 KB
testcase_01 AC 73 ms
71,604 KB
testcase_02 AC 72 ms
71,816 KB
testcase_03 AC 82 ms
75,560 KB
testcase_04 AC 96 ms
77,228 KB
testcase_05 AC 96 ms
77,092 KB
testcase_06 AC 90 ms
76,968 KB
testcase_07 AC 98 ms
76,952 KB
testcase_08 AC 96 ms
77,080 KB
testcase_09 AC 93 ms
77,116 KB
testcase_10 AC 89 ms
76,948 KB
testcase_11 AC 97 ms
77,328 KB
testcase_12 AC 94 ms
77,324 KB
testcase_13 AC 90 ms
76,944 KB
testcase_14 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.buffer.readline

    for _ in range(int(input())):
        d, a, b = map(int, input().split())
        d = d-1
        aa = a%d
        bb = b%d
        if aa == 0:
            aa = d
        if bb == 0:
            bb = d
        if aa < bb:
            print((d * (d+1) // 2) * ((b - a) // d) + ((aa + bb) * (bb-aa+1) // 2))
        elif aa > bb:
            print((d * (d + 1) // 2) * ((b - a) // d) + ((aa + d) * (d - aa + 1) // 2) + (1 + bb) * (bb - 1 + 1) // 2)
        else:
            print((d * (d + 1) // 2) * ((b - a) // d) + aa)


if __name__ == '__main__':
    main()
0