結果

問題 No.2556 Increasing Matrix
ユーザー hiro1729hiro1729
提出日時 2023-12-03 09:20:32
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 741 bytes
コンパイル時間 4,129 ms
コンパイル使用メモリ 262,752 KB
実行使用メモリ 10,260 KB
最終ジャッジ日時 2023-12-03 09:20:45
合計ジャッジ時間 12,588 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 1 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 1 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 1 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 4 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 3 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 10 ms
6,676 KB
testcase_14 AC 39 ms
6,676 KB
testcase_15 AC 32 ms
6,676 KB
testcase_16 AC 22 ms
6,676 KB
testcase_17 AC 51 ms
6,676 KB
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
long long modinv(long long a) {
	long long b = mod, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= mod; 
	if (u < 0) u += mod;
	return u;
}

int main() {
	int N;
	scanf("%d", &N);
	int A[100000];
	for (int i = 0; i < N; i++) scanf("%d", &A[i]);
	long long pw = 1, ans = 1;
	for (int i = 2; i < N; i++) {
		pw = pw * i % mod;
		ans = ans * modinv(pw) % mod;
	}
	for (int j = 0; j < N; j++) {
		for (int i = j + 1; i < N; i++) {
			ans = ans * (A[i] - A[j] + i - j) % mod;
		}
	}
	printf("%d\n", ans * ans % mod);
}
0