結果

問題 No.1839 Concatenation Matrix
ユーザー milanis48663220milanis48663220
提出日時 2022-02-11 23:37:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,642 bytes
コンパイル時間 2,813 ms
コンパイル使用メモリ 163,548 KB
実行使用メモリ 37,992 KB
最終ジャッジ日時 2023-09-10 06:37:44
合計ジャッジ時間 7,615 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

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>
#include <atcoder/convolution>

#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::modint998244353;

const int MOD = 998244353;

mint pow(mint a, ll n) {
    assert(n >= 0);
	mint ans = 1;
    while (n > 0) {
        if (n&1) ans = ans*a;
        a = a*a;
        n >>= 1;
    }
	return ans;
}

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

vector<mint> calc(vector<vector<mint>> v){
    if(v.size() == 1){
        return v[0];
    } 
    int n = v.size();
    vector<vector<mint>> vl, vr;
    for(int i = 0; i < n; i++){
        if(i*2 < n) vl.push_back(v[i]);
        else vr.push_back(v[i]);
    }
    return atcoder::convolution(calc(vl), calc(vr));
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    vector<vector<mint>> v;
    for(int i = 0; i < n-1; i++){
        mint p2 = pow(mint(2), i);
        int x = p2.val()%(MOD-1);
        mint p10 = pow(mint(10), x);
        v.push_back({p10, mint(1)});
    }
    auto u = calc(v);
    vector<mint> uu(n);
    for(int i = 0; i < n; i++){
        int j = (n-i)%n;
        uu[j] = u[i];
    }
    vector<mint> b(n);
    for(int i = 0; i < n; i++) b[i] = a[i];
    auto w = atcoder::convolution(b, uu);
    vector<mint> ans(n);
    for(int i = 0; i < 2*n; i++) ans[i%n] += w[i];
    for(int i = 0; i < n; i++) cout << ans[i] << endl;
}
0