結果
問題 | No.1261 数字集め |
ユーザー | mkawa2 |
提出日時 | 2021-08-29 10:28:52 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,949 bytes |
コンパイル時間 | 226 ms |
コンパイル使用メモリ | 81,884 KB |
実行使用メモリ | 534,500 KB |
最終ジャッジ日時 | 2024-11-22 04:16:00 |
合計ジャッジ時間 | 356,012 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | TLE | - |
testcase_01 | AC | 154 ms
241,952 KB |
testcase_02 | AC | 238 ms
334,200 KB |
testcase_03 | WA | - |
testcase_04 | AC | 194 ms
290,296 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 57 ms
229,800 KB |
testcase_11 | AC | 340 ms
413,456 KB |
testcase_12 | AC | 298 ms
405,764 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | AC | 281 ms
350,184 KB |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 273 ms
474,524 KB |
testcase_20 | WA | - |
testcase_21 | MLE | - |
testcase_22 | MLE | - |
testcase_23 | MLE | - |
testcase_24 | MLE | - |
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 | TLE | - |
testcase_45 | TLE | - |
testcase_46 | WA | - |
testcase_47 | TLE | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | TLE | - |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | TLE | - |
testcase_54 | TLE | - |
testcase_55 | WA | - |
testcase_56 | TLE | - |
testcase_57 | WA | - |
testcase_58 | TLE | - |
testcase_59 | TLE | - |
testcase_60 | TLE | - |
testcase_61 | WA | - |
testcase_62 | TLE | - |
testcase_63 | WA | - |
testcase_64 | TLE | - |
testcase_65 | WA | - |
testcase_66 | WA | - |
testcase_67 | WA | - |
testcase_68 | WA | - |
testcase_69 | WA | - |
testcase_70 | TLE | - |
testcase_71 | TLE | - |
testcase_72 | TLE | - |
testcase_73 | WA | - |
testcase_74 | WA | - |
testcase_75 | TLE | - |
testcase_76 | WA | - |
testcase_77 | WA | - |
testcase_78 | WA | - |
testcase_79 | WA | - |
testcase_80 | TLE | - |
testcase_81 | WA | - |
testcase_82 | TLE | - |
testcase_83 | TLE | - |
testcase_84 | TLE | - |
testcase_85 | TLE | - |
testcase_86 | TLE | - |
testcase_87 | TLE | - |
testcase_88 | TLE | - |
testcase_89 | TLE | - |
testcase_90 | TLE | - |
testcase_91 | TLE | - |
testcase_92 | TLE | - |
testcase_93 | TLE | - |
ソースコード
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 ot[y].append(x) print(ans)