結果

問題 No.1252 数字根D
ユーザー 👑 tamatotamato
提出日時 2020-10-09 21:50:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 761 bytes
コンパイル時間 1,667 ms
コンパイル使用メモリ 87,216 KB
実行使用メモリ 77,036 KB
最終ジャッジ日時 2023-09-27 16:23:47
合計ジャッジ時間 2,381 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
71,736 KB
testcase_01 AC 66 ms
71,584 KB
testcase_02 AC 67 ms
71,512 KB
testcase_03 AC 79 ms
75,840 KB
testcase_04 AC 86 ms
76,956 KB
testcase_05 AC 84 ms
77,012 KB
testcase_06 AC 84 ms
76,700 KB
testcase_07 AC 84 ms
76,932 KB
testcase_08 AC 90 ms
77,036 KB
testcase_09 AC 84 ms
76,868 KB
testcase_10 AC 83 ms
76,836 KB
testcase_11 AC 88 ms
76,640 KB
testcase_12 AC 85 ms
76,948 KB
testcase_13 AC 85 ms
76,888 KB
testcase_14 AC 65 ms
71,640 KB
権限があれば一括ダウンロードができます

ソースコード

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())
        if b == 0:
            print(0)
            continue
        if a == 0:
            a = 1
        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