結果

問題 No.1252 数字根D
ユーザー tktk_snsntktk_snsn
提出日時 2021-04-23 20:51:18
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 22 ms / 2,000 ms
コード長 383 bytes
コンパイル時間 128 ms
コンパイル使用メモリ 10,724 KB
実行使用メモリ 7,896 KB
最終ジャッジ日時 2023-09-17 11:19:37
合計ジャッジ時間 1,635 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,896 KB
testcase_01 AC 17 ms
7,764 KB
testcase_02 AC 15 ms
7,768 KB
testcase_03 AC 19 ms
7,868 KB
testcase_04 AC 21 ms
7,764 KB
testcase_05 AC 21 ms
7,812 KB
testcase_06 AC 21 ms
7,876 KB
testcase_07 AC 22 ms
7,848 KB
testcase_08 AC 21 ms
7,760 KB
testcase_09 AC 21 ms
7,876 KB
testcase_10 AC 22 ms
7,892 KB
testcase_11 AC 21 ms
7,868 KB
testcase_12 AC 21 ms
7,876 KB
testcase_13 AC 21 ms
7,896 KB
testcase_14 AC 16 ms
7,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)


def cnt(val, d):
    if val <= 0:
        return 0
    d -= 1
    div, mod = divmod(val, d)
    res = d * (d + 1)//2 * div + mod * (mod + 1) // 2
    return res


def test():
    d, A, B = map(int, input().split())
    return cnt(B, d) - cnt(A-1, d)


T = int(input())
for _ in range(T):
    print(test())
0