結果
| 問題 |
No.723 2つの数の和
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-03-15 06:20:51 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,057 bytes |
| コンパイル時間 | 4,492 ms |
| コンパイル使用メモリ | 224,900 KB |
| 実行使用メモリ | 19,376 KB |
| 最終ジャッジ日時 | 2025-03-15 06:21:03 |
| 合計ジャッジ時間 | 11,667 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | TLE * 1 -- * 2 |
| other | -- * 22 |
ソースコード
#include <bits/stdc++.h>
#define rep(i, p, n) for (ll i = p; i < (ll)(n); i++)
#define rep2(i, p, n) for (ll i = p; i >= (ll)(n); i--)
using namespace std;
using ll = long long;
using ld = long double;
const double pi = 3.141592653589793;
const long long inf = 2 * 1e9;
const long long linf = 4 * 1e18;
const ll mod1 = 1000000007;
const ll mod2 = 998244353;
template <class T>
inline bool chmax(T &a, T b)
{
if (a < b)
{
a = b;
return 1;
}
return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
if (a > b)
{
a = b;
return 1;
}
return 0;
}
// atcoder
#include <atcoder/all>
using namespace atcoder;
// using mint1 = modint1000000007;
// using mint2 = modint998244353;
using mint = modint998244353;
vector<pair<ll, ll>> base = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
template <typename mint>
struct FormalPowerSeries : vector<mint> {
using vector<mint>::vector;
FormalPowerSeries& operator+=(const FormalPowerSeries& r) {
if (r.size() > this->size()) this->resize(r.size());
for (size_t i = 0; i < r.size(); i++) (*this)[i] += r[i];
return *this;
}
FormalPowerSeries operator*(const FormalPowerSeries& r) const {
FormalPowerSeries res(this->size() + r.size() - 1);
for (size_t i = 0; i < this->size(); i++)
for (size_t j = 0; j < r.size(); j++)
res[i + j] += (*this)[i] * r[j];
return res;
}
};
// 定数
const int MAX_A = 100000;
int main()
{
//////////////////
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
//////////////////
int N;
long long X;
cin >> N >> X;
vector<int> a(N);
for (int i = 0; i < N; ++i) cin >> a[i];
vector<mint> freq(MAX_A + 1, 0);
for (int num : a) freq[num] += 1;
FormalPowerSeries<mint> P(MAX_A + 1);
for (int i = 0; i <= MAX_A; ++i) P[i] = freq[i];
auto C = P * P;
mint result = 0;
if (X <= 2 * MAX_A) result = C[X];
cout << result.val() << '\n';
return 0;
}