結果

問題 No.1396 Giri
ユーザー さかぽんさかぽん
提出日時 2021-02-16 17:08:11
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 137 ms / 2,000 ms
コード長 601 bytes
コンパイル時間 3,839 ms
コンパイル使用メモリ 103,116 KB
実行使用メモリ 25,932 KB
最終ジャッジ日時 2023-10-11 05:16:38
合計ジャッジ時間 7,860 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
20,700 KB
testcase_01 AC 56 ms
20,704 KB
testcase_02 AC 135 ms
23,988 KB
testcase_03 AC 55 ms
20,660 KB
testcase_04 AC 56 ms
22,764 KB
testcase_05 AC 136 ms
23,984 KB
testcase_06 AC 55 ms
20,628 KB
testcase_07 AC 55 ms
20,592 KB
testcase_08 AC 55 ms
20,828 KB
testcase_09 AC 55 ms
20,808 KB
testcase_10 AC 56 ms
18,764 KB
testcase_11 AC 55 ms
20,624 KB
testcase_12 AC 55 ms
22,612 KB
testcase_13 AC 57 ms
22,704 KB
testcase_14 AC 55 ms
20,756 KB
testcase_15 AC 56 ms
20,676 KB
testcase_16 AC 55 ms
20,624 KB
testcase_17 AC 56 ms
20,680 KB
testcase_18 AC 60 ms
22,692 KB
testcase_19 AC 94 ms
20,224 KB
testcase_20 AC 112 ms
23,048 KB
testcase_21 AC 129 ms
25,636 KB
testcase_22 AC 136 ms
23,936 KB
testcase_23 AC 137 ms
25,932 KB
testcase_24 AC 137 ms
23,976 KB
testcase_25 AC 136 ms
24,140 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

class B
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());

		long r = 1, pMax = 1;
		var a = new int[n + 1];
		for (int i = 0; i <= n; i++) a[i] = i;

		for (int i = 2; i <= n; i++)
		{
			var p = a[i];

			r *= p;
			r %= M;
			pMax = Math.Max(pMax, p);

			for (int j = i; j <= n; j += i)
				a[j] /= p;
		}

		Console.WriteLine(r * MInv(pMax) % M);
	}

	const long M = 998244353;
	static long MPow(long b, long i)
	{
		long r = 1;
		for (; i != 0; b = b * b % M, i >>= 1) if ((i & 1) != 0) r = r * b % M;
		return r;
	}
	static long MInv(long x) => MPow(x, M - 2);
}
0