結果

問題 No.2344 (l+r)^2
ユーザー KudeKude
提出日時 2023-06-09 22:51:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 121 ms / 2,000 ms
コード長 1,879 bytes
コンパイル時間 2,681 ms
コンパイル使用メモリ 229,124 KB
実行使用メモリ 4,708 KB
最終ジャッジ日時 2023-08-30 14:01:15
合計ジャッジ時間 4,280 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 63 ms
4,380 KB
testcase_02 AC 31 ms
4,376 KB
testcase_03 AC 31 ms
4,380 KB
testcase_04 AC 31 ms
4,380 KB
testcase_05 AC 32 ms
4,380 KB
testcase_06 AC 31 ms
4,376 KB
testcase_07 AC 31 ms
4,380 KB
testcase_08 AC 31 ms
4,376 KB
testcase_09 AC 29 ms
4,380 KB
testcase_10 AC 38 ms
4,380 KB
testcase_11 AC 25 ms
4,376 KB
testcase_12 AC 121 ms
4,708 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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';
  }
}
0