結果

問題 No.752 mod数列
ユーザー gew1fw
提出日時 2025-06-12 12:59:57
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 742 bytes
コンパイル時間 339 ms
コンパイル使用メモリ 82,172 KB
実行使用メモリ 98,776 KB
最終ジャッジ日時 2025-06-12 13:06:00
合計ジャッジ時間 7,033 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other AC * 16 TLE * 1 -- * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def main():
    input = sys.stdin.read().split()
    ptr = 0
    P = int(input[ptr])
    ptr += 1
    Q = int(input[ptr])
    ptr += 1
    
    for _ in range(Q):
        L = int(input[ptr])
        ptr += 1
        R = int(input[ptr])
        ptr += 1
        
        current = L
        s = 0
        while current <= R:
            q = P // current
            if q == 0:
                next_n = R + 1
            else:
                next_n = min(R, P // q)
            count = next_n - current + 1
            sum_n = (current + next_n) * count // 2
            s += q * sum_n
            current = next_n + 1
        
        total = (R - L + 1) * P - s
        print(total)
        
if __name__ == "__main__":
    main()
0