結果

問題 No.2396 等差二項展開
ユーザー milanis48663220milanis48663220
提出日時 2023-07-28 22:26:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,419 bytes
コンパイル時間 1,335 ms
コンパイル使用メモリ 122,912 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 06:24:12
合計ジャッジ時間 9,976 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 WA -
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 3 ms
5,376 KB
testcase_15 AC 9 ms
5,376 KB
testcase_16 AC 114 ms
5,376 KB
testcase_17 AC 484 ms
5,376 KB
testcase_18 AC 779 ms
5,376 KB
testcase_19 AC 930 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 WA -
testcase_23 AC 405 ms
5,376 KB
testcase_24 AC 658 ms
5,376 KB
testcase_25 AC 781 ms
5,376 KB
testcase_26 AC 570 ms
5,376 KB
testcase_27 AC 633 ms
5,376 KB
testcase_28 AC 698 ms
5,376 KB
testcase_29 AC 637 ms
5,376 KB
testcase_30 AC 458 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>
#include <atcoder/modint>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

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; }

using namespace std;
typedef long long ll;

template<typename T>
vector<vector<T>> vec2d(int n, int m, T v){
    return vector<vector<T>>(n, vector<T>(m, v));
}

template<typename T>
vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){
    return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v)));
}

template<typename T>
void print_vector(vector<T> v, char delimiter=' '){
    if(v.empty()) {
        cout << endl;
        return;
    }
    for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter;
    cout << v.back() << endl;
}

using mint = atcoder::modint;

ostream& operator<<(ostream& os, const mint& m){
    os << m.val();
    return os;
}


ll mod_pow(ll a, ll n, ll mod) {
    ll ans = 1;
    
    return ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    ll n, m; int l, k, b; cin >> n >> m >> l >> k >> b;
    mint::set_mod(b);
    vector<mint> ans(l), a(l);
    ans[0] = 1;
    a[0] = 1;
    a[1%l] += 1;
    while (n > 0) {
        if (n&1) {
            vector<mint> nx(l);
            for(int i = 0; i < l; i++){
                for(int j = 0; j < l; j++){
                    if(i+j >= l){
                        nx[(i+j)%l] += ans[i]*a[j]*m;
                    }else{
                        nx[(i+j)%l] += ans[i]*a[j];
                    }
                }
            }
            ans = nx;
        }
        vector<mint> nx(l);
        for(int i = 0; i < l; i++){
            for(int j = 0; j < l; j++){
               if(i+j >= l){
                    nx[(i+j)%l] += a[i]*a[j]*m;
                }else{
                    nx[(i+j)%l] += a[i]*a[j];
                }
            }
        }
        a = nx;
        n >>= 1;
    }
    cout << ans[k] << endl;
}
0