結果
問題 | No.2344 (l+r)^2 |
ユーザー |
![]() |
提出日時 | 2023-06-09 22:51:23 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 122 ms / 2,000 ms |
コード長 | 1,879 bytes |
コンパイル時間 | 2,300 ms |
コンパイル使用メモリ | 221,360 KB |
最終ジャッジ日時 | 2025-02-14 00:21:42 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 12 |
ソースコード
#include<bits/stdc++.h>namespace {#pragma GCC diagnostic ignored "-Wunused-function"#include<atcoder/all>#pragma GCC diagnostic warning "-Wunused-function"using namespace std;using namespace atcoder;#define rep(i,n) for(int i = 0; i < (int)(n); i++)#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)#define all(x) begin(x), end(x)#define rall(x) rbegin(x), rend(x)template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }using ll = long long;using P = pair<int,int>;using VI = vector<int>;using VVI = vector<VI>;using VL = vector<ll>;using VVL = vector<VL>;using mint = modint;} int main() {ios::sync_with_stdio(false);cin.tie(0);int tt;cin >> tt;while(tt--) {int n, m;cin >> n >> m;mint::set_mod(1 << m);vector<mint> a(n);for(mint& x: a) {int xi;cin >> xi;x = xi;}vector<mint> b;if (n > 33) {b.assign(33, mint());const int t = n - 33;vector<mint> comb(t + 1);{mint p = 1, q = 1;int c2 = 0;for(int k = 0; k <= t; k++) {comb[k] = p / q * mint::raw(2).pow(c2);if (k < t) {int x = t - k, y = k + 1;while(x % 2 == 0) x /= 2, c2++;while(y % 2 == 0) y /= 2, c2--;p *= x;q *= y;}}}rep(i, n) {rep(j, 33) {int k = i - j;if (0 <= k && k <= t) b[j] += comb[k] * a[i];}}swap(a, b);}while(a.size() != 1) {int n = a.size();b.resize(n - 1);rep(i, n - 1) {mint v = a[i] + a[i+1];b[i] = v * v;}swap(a, b);}cout << a[0].val() << '\n';}}