結果

問題 No.1310 量子アニーリング
ユーザー さかぽんさかぽん
提出日時 2020-12-14 11:00:25
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 219 ms / 2,000 ms
コード長 1,089 bytes
コンパイル時間 1,714 ms
コンパイル使用メモリ 110,664 KB
実行使用メモリ 24,568 KB
最終ジャッジ日時 2023-10-20 04:55:23
合計ジャッジ時間 4,160 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
23,992 KB
testcase_01 AC 25 ms
23,992 KB
testcase_02 AC 25 ms
23,992 KB
testcase_03 AC 26 ms
23,992 KB
testcase_04 AC 26 ms
23,992 KB
testcase_05 AC 24 ms
23,992 KB
testcase_06 AC 26 ms
23,992 KB
testcase_07 AC 25 ms
23,992 KB
testcase_08 AC 24 ms
23,992 KB
testcase_09 AC 25 ms
23,992 KB
testcase_10 AC 26 ms
23,992 KB
testcase_11 AC 26 ms
23,992 KB
testcase_12 AC 31 ms
23,992 KB
testcase_13 AC 77 ms
23,992 KB
testcase_14 AC 100 ms
23,992 KB
testcase_15 AC 119 ms
23,992 KB
testcase_16 AC 125 ms
23,992 KB
testcase_17 AC 167 ms
24,164 KB
testcase_18 AC 219 ms
24,568 KB
testcase_19 AC 109 ms
23,992 KB
testcase_20 AC 61 ms
23,992 KB
testcase_21 AC 47 ms
23,992 KB
testcase_22 AC 218 ms
24,560 KB
testcase_23 AC 79 ms
23,992 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 G
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());

		var ncr = new MInt[n + 1];
		ncr[0] = 1;
		for (int i = 0; i < n; i++)
			ncr[i + 1] = ncr[i] * (n - i) / (i + 1);

		MInt r = 0;
		for (int d = 0; d <= n; d += 2)
			r += 2 * ncr[d] * MInt.MPow(2, Math.Abs(2 * d - n));
		Console.WriteLine(r);
	}
}

struct MInt
{
	const long M = 998244353;
	public long V;
	public MInt(long v) { V = (v %= M) < 0 ? v + M : v; }
	public override string ToString() => $"{V}";
	public static implicit operator MInt(long v) => new MInt(v);

	public static MInt operator -(MInt x) => -x.V;
	public static MInt operator +(MInt x, MInt y) => x.V + y.V;
	public static MInt operator -(MInt x, MInt y) => x.V - y.V;
	public static MInt operator *(MInt x, MInt y) => x.V * y.V;
	public static MInt operator /(MInt x, MInt y) => x.V * y.Inv().V;

	public 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;
	}
	public MInt Pow(long i) => MPow(V, i);
	public MInt Inv() => MPow(V, M - 2);
}
0