結果
問題 | No.2318 Phys Bone Maker |
ユーザー | kakel-san |
提出日時 | 2023-08-03 22:52:38 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 3,400 bytes |
コンパイル時間 | 1,283 ms |
コンパイル使用メモリ | 115,284 KB |
実行使用メモリ | 445,428 KB |
最終ジャッジ日時 | 2024-10-13 20:02:41 |
合計ジャッジ時間 | 25,863 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 33 ms
18,944 KB |
testcase_01 | AC | 31 ms
18,944 KB |
testcase_02 | TLE | - |
testcase_03 | AC | 54 ms
18,816 KB |
testcase_04 | AC | 61 ms
18,816 KB |
testcase_05 | AC | 46 ms
18,944 KB |
testcase_06 | AC | 50 ms
18,816 KB |
testcase_07 | AC | 38 ms
18,688 KB |
testcase_08 | AC | 68 ms
18,688 KB |
testcase_09 | AC | 52 ms
18,688 KB |
testcase_10 | AC | 77 ms
18,944 KB |
testcase_11 | AC | 89 ms
18,688 KB |
testcase_12 | AC | 133 ms
18,688 KB |
testcase_13 | AC | 110 ms
19,328 KB |
testcase_14 | AC | 66 ms
18,560 KB |
testcase_15 | AC | 64 ms
18,688 KB |
testcase_16 | AC | 53 ms
18,944 KB |
testcase_17 | AC | 71 ms
18,816 KB |
testcase_18 | AC | 116 ms
18,816 KB |
testcase_19 | AC | 44 ms
18,944 KB |
testcase_20 | AC | 57 ms
18,688 KB |
testcase_21 | AC | 51 ms
18,816 KB |
testcase_22 | AC | 50 ms
18,944 KB |
testcase_23 | AC | 50 ms
18,816 KB |
testcase_24 | AC | 70 ms
18,944 KB |
testcase_25 | AC | 72 ms
18,688 KB |
testcase_26 | AC | 71 ms
18,688 KB |
testcase_27 | AC | 58 ms
18,688 KB |
testcase_28 | AC | 48 ms
18,816 KB |
testcase_29 | AC | 46 ms
18,816 KB |
testcase_30 | AC | 45 ms
18,816 KB |
testcase_31 | AC | 91 ms
18,816 KB |
testcase_32 | AC | 60 ms
18,944 KB |
testcase_33 | AC | 30 ms
18,816 KB |
testcase_34 | AC | 68 ms
18,688 KB |
testcase_35 | AC | 337 ms
65,536 KB |
testcase_36 | AC | 1,244 ms
222,208 KB |
testcase_37 | AC | 1,281 ms
224,128 KB |
testcase_38 | AC | 1,486 ms
226,432 KB |
testcase_39 | AC | 1,924 ms
321,280 KB |
testcase_40 | AC | 2,011 ms
323,328 KB |
testcase_41 | AC | 2,274 ms
366,592 KB |
testcase_42 | AC | 2,382 ms
370,816 KB |
testcase_43 | AC | 119 ms
19,200 KB |
testcase_44 | AC | 695 ms
59,904 KB |
testcase_45 | AC | 637 ms
58,240 KB |
testcase_46 | AC | 2,723 ms
376,064 KB |
testcase_47 | AC | 61 ms
18,944 KB |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { public static void Main() { Solve(); } static void Solve() { var n = long.Parse(ReadLine()); var plist = PList(n); var map = new List<long>[plist.Count]; for (var i = 0; i < map.Length; ++i) map[i] = PList(plist[i]); var rev = new Dictionary<long, int>(); for (var i = 0; i < plist.Count; ++i) rev[plist[i]] = i; var dic = PDiv(n); var primes = new List<long>(dic.Select(kv => kv.Key)); primes.Sort(); var pcntmap = new int[plist.Count][]; for (var i = 0; i < pcntmap.Length; ++i) { pcntmap[i] = new int[primes.Count]; for (var j = 0; j < pcntmap[i].Length; ++j) { var tmp = plist[i]; while (tmp % primes[j] == 0) { ++pcntmap[i][j]; tmp /= primes[j]; } } } // WriteLine("p: " + string.Join(" ", primes)); // WriteLine(string.Join("\n", pcntmap.Select((pi, i) => $"{plist[i]}: {string.Join(" ", pi)}"))); var dp = new long[plist.Count][]; for (var i = 0; i < dp.Length; ++i) dp[i] = new long[plist.Count]; dp[0][0] = 1; var mod = 998_244_353; for (var m = 0; m + 1 < dp.Length; ++m) for (var i = 0; i + 1 < dp[m].Length; ++i) { // if (m % 100 == 0 && i == 0) WriteLine($"m = {m}"); if (dp[m][i] == 0) continue; foreach (var r in map[map.Length - 1 - i]) { if (r == 1) continue; var next = rev[plist[i] * r]; var add = dp[m][i]; for (var q = 0; q < primes.Count; ++q) { if (pcntmap[i][q] == pcntmap[next][q]) add = add * (pcntmap[i][q] + 1); } // WriteLine($"{m} {i} to {next} ({plist[i]} to {plist[i]} * {r}) : add {add}"); dp[m + 1][next] = (dp[m + 1][next] + add % mod) % mod; } } var ans = 0L; for (var i = 1; i < dp.Length; ++i) ans = (ans + dp[i][dp[i].Length - 1]) % mod; WriteLine(ans); } static List<long> PList(long n) { var list = new List<long>(); var rev = new List<long>(); for (var i = 1L; i * i <= n; ++i) { if (n % i == 0) { list.Add(i); if (i * i < n) rev.Add(n / i); } } rev.Reverse(); list.AddRange(rev); return list; } static Dictionary<long, int> PDiv(long n) { var dic = new Dictionary<long, int>(); var tmp = n; while (tmp % 2 == 0) { tmp /= 2; if (dic.ContainsKey(2)) ++dic[2]; else dic.Add(2, 1); } for (var p = 3L; p * p <= n; p += 2) { while (tmp % p == 0) { tmp /= p; if (dic.ContainsKey(p)) ++dic[p]; else dic.Add(p, 1); } if (tmp == 1) break; } if (tmp > 1) dic.Add(tmp, 1); return dic; } }