結果
問題 |
No.2380 Sylow P-subgroup
|
ユーザー |
|
提出日時 | 2023-07-14 22:57:22 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,017 bytes |
コンパイル時間 | 2,146 ms |
コンパイル使用メモリ | 105,344 KB |
実行使用メモリ | 18,944 KB |
最終ジャッジ日時 | 2024-09-16 08:04:31 |
合計ジャッジ時間 | 2,466 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 WA * 1 |
コンパイルメッセージ
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 { static long NN => long.Parse(ReadLine()); static long[] NList => ReadLine().Split().Select(long.Parse).ToArray(); public static void Main() { Solve(); } static void Solve() { var c = NList; var (n, p) = (c[0], c[1]); var mul = 0L; var tmp = p; var mod = 998_244_353; checked { while (true) { if (tmp > n) break; // mul = (mul + n / tmp) % mod; mul += n / tmp; tmp *= p; } } WriteLine(Exp((int)p, (int)(mul % mod), mod)); } static long Exp(int n, int k, int mod) { if (k == 0) return 1; if (k == 1) return n % mod; var half = Exp(n, k / 2, mod); var result = (half * half) % mod; return ((k % 2) == 0) ? result : ((result * n) % mod); } }