結果
問題 | No.1261 数字集め |
ユーザー | mkawa2 |
提出日時 | 2021-08-29 10:34:33 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,956 bytes |
コンパイル時間 | 436 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 272,824 KB |
最終ジャッジ日時 | 2024-11-22 04:18:43 |
合計ジャッジ時間 | 48,745 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 178 ms
131,904 KB |
testcase_02 | AC | 259 ms
186,820 KB |
testcase_03 | WA | - |
testcase_04 | AC | 211 ms
175,348 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 68 ms
68,096 KB |
testcase_11 | AC | 390 ms
249,436 KB |
testcase_12 | AC | 324 ms
230,580 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | AC | 310 ms
212,752 KB |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 302 ms
212,568 KB |
testcase_20 | WA | - |
testcase_21 | AC | 351 ms
272,680 KB |
testcase_22 | AC | 351 ms
272,824 KB |
testcase_23 | AC | 352 ms
272,688 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | AC | 559 ms
244,728 KB |
testcase_45 | WA | - |
testcase_46 | AC | 222 ms
184,384 KB |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | AC | 212 ms
113,980 KB |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | WA | - |
testcase_60 | WA | - |
testcase_61 | WA | - |
testcase_62 | WA | - |
testcase_63 | WA | - |
testcase_64 | WA | - |
testcase_65 | WA | - |
testcase_66 | WA | - |
testcase_67 | WA | - |
testcase_68 | WA | - |
testcase_69 | AC | 286 ms
184,588 KB |
testcase_70 | WA | - |
testcase_71 | WA | - |
testcase_72 | WA | - |
testcase_73 | WA | - |
testcase_74 | WA | - |
testcase_75 | WA | - |
testcase_76 | WA | - |
testcase_77 | WA | - |
testcase_78 | WA | - |
testcase_79 | WA | - |
testcase_80 | WA | - |
testcase_81 | WA | - |
testcase_82 | WA | - |
testcase_83 | WA | - |
testcase_84 | WA | - |
testcase_85 | WA | - |
testcase_86 | WA | - |
testcase_87 | WA | - |
testcase_88 | WA | - |
testcase_89 | WA | - |
testcase_90 | WA | - |
testcase_91 | WA | - |
testcase_92 | WA | - |
testcase_93 | WA | - |
ソースコード
import sys # sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() # dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = 10**9 # md = 998244353 md = 10**9+7 from functools import lru_cache def factors(a): if a <= 0: return [0] dd0, dd1 = [], [] for d in range(1, a+1): if d*d > a: break if a%d: continue dd0.append(d) dd1.append(a//d) if dd0[-1] == dd1[-1]: dd1.pop() return dd0+dd1[::-1] def cal(a, b): c = aa[-1]-1 if a == b == c: return pow(b[0], m, md)*((m+2)*(m+1)//2)%md if a == c: b, c = c, b if b == c: a, c = c, a if a == b: am = pow(a, m+1, md) return (-c*(m+2)*am%md+(m+1)*a*am%md+pow(c, m+2, md))*pow(a-c, 2*md-4, md)%md return (pow(a, m+2, md)*(b-c)+pow(c, m+1, md)*(a*c-b*c)+pow(b, m+1, md)*(-a*b+b*c))*pow((a-b)*(a-c)*(b-c), md-2, md)%md n, m = LI() m -= 3 aa = [0, 0]+LI() ff = factors(n)[1:-1] ton = [False]*(n+1) ans = 0 for i, f in enumerate(ff): ton[f] = True for g in ff[i+1:]: if g%f: continue ans += cal(aa[f]-1, aa[g]-1) # print(f,g,ans) print(ans) ot=[[] for _ in range(n+1)] for _ in range(II()): x, y = LI() if y == n: for f in factors(x)[1:-1]+ot[y]: ans = (ans+cal(aa[f]-1, aa[x]-1))%md ton[x] = True elif ton[y]: ans = (ans+cal(aa[x]-1, aa[y]-1))%md if y<n:ot[y].append(x) print(ans)