結果

問題 No.1261 数字集め
ユーザー chineristACchineristAC
提出日時 2020-10-16 23:16:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 3,235 ms / 8,000 ms
コード長 1,071 bytes
コンパイル時間 509 ms
コンパイル使用メモリ 87,144 KB
実行使用メモリ 260,928 KB
最終ジャッジ日時 2023-09-28 11:40:40
合計ジャッジ時間 51,964 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3,235 ms
251,772 KB
testcase_01 AC 182 ms
132,376 KB
testcase_02 AC 284 ms
179,060 KB
testcase_03 AC 284 ms
179,204 KB
testcase_04 AC 217 ms
158,812 KB
testcase_05 AC 349 ms
237,028 KB
testcase_06 AC 237 ms
174,436 KB
testcase_07 AC 289 ms
186,524 KB
testcase_08 AC 204 ms
146,528 KB
testcase_09 AC 255 ms
184,644 KB
testcase_10 AC 88 ms
79,144 KB
testcase_11 AC 351 ms
232,260 KB
testcase_12 AC 317 ms
206,312 KB
testcase_13 AC 308 ms
200,184 KB
testcase_14 AC 105 ms
89,912 KB
testcase_15 AC 197 ms
142,412 KB
testcase_16 AC 291 ms
186,556 KB
testcase_17 AC 266 ms
201,264 KB
testcase_18 AC 198 ms
142,496 KB
testcase_19 AC 292 ms
181,116 KB
testcase_20 AC 117 ms
93,648 KB
testcase_21 AC 374 ms
259,220 KB
testcase_22 AC 369 ms
260,072 KB
testcase_23 AC 368 ms
259,444 KB
testcase_24 AC 390 ms
259,708 KB
testcase_25 AC 396 ms
259,424 KB
testcase_26 AC 417 ms
260,504 KB
testcase_27 AC 380 ms
259,488 KB
testcase_28 AC 382 ms
260,928 KB
testcase_29 AC 388 ms
259,824 KB
testcase_30 AC 379 ms
260,276 KB
testcase_31 AC 399 ms
259,460 KB
testcase_32 AC 389 ms
259,832 KB
testcase_33 AC 384 ms
259,312 KB
testcase_34 AC 393 ms
259,412 KB
testcase_35 AC 384 ms
259,332 KB
testcase_36 AC 381 ms
259,596 KB
testcase_37 AC 386 ms
260,924 KB
testcase_38 AC 385 ms
259,468 KB
testcase_39 AC 384 ms
259,532 KB
testcase_40 AC 380 ms
259,600 KB
testcase_41 AC 401 ms
259,900 KB
testcase_42 AC 386 ms
259,376 KB
testcase_43 AC 380 ms
260,420 KB
testcase_44 AC 519 ms
228,420 KB
testcase_45 AC 319 ms
107,484 KB
testcase_46 AC 229 ms
168,764 KB
testcase_47 AC 351 ms
133,596 KB
testcase_48 AC 417 ms
181,184 KB
testcase_49 AC 432 ms
228,308 KB
testcase_50 AC 513 ms
204,872 KB
testcase_51 AC 210 ms
106,352 KB
testcase_52 AC 189 ms
80,232 KB
testcase_53 AC 307 ms
108,232 KB
testcase_54 AC 375 ms
111,180 KB
testcase_55 AC 242 ms
95,952 KB
testcase_56 AC 308 ms
101,168 KB
testcase_57 AC 392 ms
177,328 KB
testcase_58 AC 278 ms
107,476 KB
testcase_59 AC 551 ms
222,724 KB
testcase_60 AC 309 ms
110,620 KB
testcase_61 AC 302 ms
133,820 KB
testcase_62 AC 564 ms
206,160 KB
testcase_63 AC 182 ms
99,192 KB
testcase_64 AC 610 ms
230,208 KB
testcase_65 AC 363 ms
199,068 KB
testcase_66 AC 308 ms
184,092 KB
testcase_67 AC 343 ms
204,832 KB
testcase_68 AC 330 ms
171,568 KB
testcase_69 AC 257 ms
169,868 KB
testcase_70 AC 369 ms
144,280 KB
testcase_71 AC 511 ms
202,040 KB
testcase_72 AC 310 ms
115,756 KB
testcase_73 AC 335 ms
126,816 KB
testcase_74 AC 230 ms
101,172 KB
testcase_75 AC 401 ms
155,604 KB
testcase_76 AC 389 ms
177,252 KB
testcase_77 AC 436 ms
204,892 KB
testcase_78 AC 210 ms
80,436 KB
testcase_79 AC 423 ms
207,196 KB
testcase_80 AC 238 ms
80,060 KB
testcase_81 AC 219 ms
89,432 KB
testcase_82 AC 413 ms
166,900 KB
testcase_83 AC 383 ms
124,116 KB
testcase_84 AC 674 ms
251,400 KB
testcase_85 AC 694 ms
251,560 KB
testcase_86 AC 670 ms
252,120 KB
testcase_87 AC 657 ms
251,528 KB
testcase_88 AC 664 ms
252,256 KB
testcase_89 AC 664 ms
251,204 KB
testcase_90 AC 657 ms
251,464 KB
testcase_91 AC 659 ms
251,224 KB
testcase_92 AC 673 ms
252,108 KB
testcase_93 AC 649 ms
252,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

input = sys.stdin.readline

N,M = map(int,input().split())
A = [0,0] + list(map(int,input().split()))
mod = 10**9+7

def calc(x,y,z=N):
    inv = (A[x]-A[y])*(A[y]-A[z])*(A[z]-A[x])
    tmp = (A[z]-A[x]) * (pow(A[z]-1,M-1,mod) - pow(A[y]-1,M-1,mod))
    tmp %= mod
    tmp += (A[y]-A[z]) * (pow(A[z]-1,M-1,mod) - pow(A[x]-1,M-1,mod))
    tmp %= mod
    tmp = (tmp * pow(inv,mod-2,mod)) % mod
    return tmp

Q = int(input())
query = [tuple(map(int,input().split())) for i in range(Q)]

t = [-1 for i in range(N+1)]
for i in range(Q):
    x,y = query[i]
    if y==N:
        t[x] = i+1
for i in range(2,N):
    if N%i==0:
        t[i] = 0

ans = [0 for i in range(Q+1)]

for i in range(2,N+1):
    for j in range(2,N//i+1):
        if t[i*j]!=-1:
            ans[t[i*j]] += calc(i,i*j)
            ans[t[i*j]] %= mod

for i in range(Q):
    x,y = query[i]
    if y!=N and t[y]!=-1:
        ans[max(i+1,t[y])] += calc(x,y)
        ans[max(i+1,t[y])] %= mod

for i in range(1,Q+1):
    ans[i] += ans[i-1]
    ans[i] %= mod

for i in range(Q+1):
    print(ans[i])
0