結果
| 問題 |
No.3123 Inversion
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-04-19 15:43:22 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 802 bytes |
| コンパイル時間 | 2,009 ms |
| コンパイル使用メモリ | 193,864 KB |
| 実行使用メモリ | 42,444 KB |
| 最終ジャッジ日時 | 2025-04-19 15:43:38 |
| 合計ジャッジ時間 | 13,075 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | AC * 2 WA * 19 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 5000000;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int T;
long long M;
cin >> T >> M;
vector<long long> fact(MAX_N + 1);
if (M == 1) {
while (T--) {
int N;
cin >> N;
cout << "0\n";
}
return 0;
}
fact[0] = 1 % M;
for (int i = 1; i <= MAX_N; ++i) {
fact[i] = (fact[i-1] * i) % M;
}
while (T--) {
int N;
cin >> N;
if (N == 1) {
cout << 1 % M << "\n";
} else {
long long res = (4LL * fact[N] - 4LL) % M;
if (res < 0) {
res += M;
}
cout << res % M << "\n";
}
}
return 0;
}