結果

問題 No.1252 数字根D
ユーザー realDivineJKrealDivineJK
提出日時 2020-10-09 23:00:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 348 bytes
コンパイル時間 86 ms
コンパイル使用メモリ 10,520 KB
実行使用メモリ 7,948 KB
最終ジャッジ日時 2023-09-27 19:14:30
合計ジャッジ時間 1,324 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
7,948 KB
testcase_01 AC 13 ms
7,760 KB
testcase_02 AC 16 ms
7,916 KB
testcase_03 AC 22 ms
7,820 KB
testcase_04 AC 31 ms
7,816 KB
testcase_05 AC 27 ms
7,772 KB
testcase_06 AC 28 ms
7,824 KB
testcase_07 AC 27 ms
7,772 KB
testcase_08 AC 28 ms
7,796 KB
testcase_09 AC 28 ms
7,772 KB
testcase_10 AC 28 ms
7,784 KB
testcase_11 AC 27 ms
7,784 KB
testcase_12 AC 28 ms
7,768 KB
testcase_13 AC 31 ms
7,896 KB
testcase_14 AC 14 ms
7,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())
for _ in range(T):
    d, A, B = map(int, input().split())
    LM, RM = (A - 2) % (d - 1) + 1, (B - 1) % (d - 1) % (d - 1) + 1
    L = ((A - 2) // (d - 1)) * (d * (d - 1) // 2) + LM * (LM + 1) // 2
    R = ((B - 1) // (d - 1)) * (d * (d - 1) // 2) + RM * (RM + 1) // 2
    if A == 0:
        print(R)
    else:
        print(R - L)
0