結果
| 問題 |
No.752 mod数列
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2025-03-27 01:52:40 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 825 bytes |
| コンパイル時間 | 528 ms |
| コンパイル使用メモリ | 82,048 KB |
| 実行使用メモリ | 85,164 KB |
| 最終ジャッジ日時 | 2025-03-27 01:52:48 |
| 合計ジャッジ時間 | 8,249 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 RE * 18 |
ソースコード
import sys
input = sys.stdin.readline
P,Q=map(int,input().split())
S=[0]*(10**6)
for i in range(1,10**6):
S[i]=P%i
for i in range(1,10**6):
S[i]=S[i]+S[i-1]
LIST=[]
for i in range(1,10**6):
LIST.append((P//i,i))
if P//i<10**6:
break
LIST.reverse()
def calc(x):
if x<10**6:
return S[x]
else:
ANS=S[10**6-1]
now=10**6
for i in range(1,len(LIST)):
MAX=min(x,LIST[i][0])
# now~MAXの個数
ko=MAX-now+1
ANS+=P*ko-ko*(MAX+now)//2*LIST[i][1]
if x<=LIST[i][0]:
return ANS
else:
now=LIST[i][0]+1
for i in range(Q):
x,y=map(int,input().split())
minus=calc(x-1)
plus=calc(y)
print(plus-minus)
titia