結果

問題 No.2396 等差二項展開
ユーザー SSRSSSRS
提出日時 2023-07-28 21:40:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 674 bytes
コンパイル時間 1,689 ms
コンパイル使用メモリ 168,060 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 05:31:07
合計ジャッジ時間 13,270 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 1,365 ms
5,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 2 ms
5,376 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N, M;
  int L, K;
  long long B;
  cin >> N >> M >> L >> K >> B;
  auto convolution = [&](vector<long long> a, vector<long long> b){
    vector<long long> c(L, 0);
    for (int i = 0; i < L; i++){
      for (int j = 0; j < L; j++){
        c[(i + j) % L] += a[i] * b[j];
        c[(i + j) % L] %= B;
      }
    }
    return c;
  };
  vector<long long> f(L, 0);
  f[0] += 1;
  f[0] %= B;
  f[1 % L] += M;
  f[1 % L] %= B;
  vector<long long> g(L, 0);
  g[0] = 1;
  while (N > 0){
    if (N % 2 == 1){
      g = convolution(g, f);
    }
    f = convolution(f, f);
    N /= 2;
  }
  cout << g[K] << endl;
}
0