結果
問題 | No.931 Multiplicative Convolution |
ユーザー | AC2K |
提出日時 | 2023-06-18 21:53:18 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,052 bytes |
コンパイル時間 | 6,148 ms |
コンパイル使用メモリ | 317,192 KB |
実行使用メモリ | 7,804 KB |
最終ジャッジ日時 | 2024-06-26 08:56:45 |
合計ジャッジ時間 | 7,550 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
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 | - |
ソースコード
#line 1 "main.cpp" #include <atcoder/all> #line 2 "library/src/stream.hpp" #include <ctype.h> #include <stdio.h> #include <string> namespace kyopro { /** * 整数の入出力 */ template <typename T> constexpr inline void readint(T& a) { a = 0; bool is_negative = false; char c = getchar_unlocked(); while (isspace(c)) { c = getchar_unlocked(); } if (c == '-') is_negative = true, c = getchar_unlocked(); while (isdigit(c)) { a = 10 * a + (c - '0'); c = getchar_unlocked(); } if (is_negative) a *= -1; } template <typename Head, typename... Tail> constexpr inline void readint(Head& head, Tail&... tail) { readint(head); readint(tail...); } template <typename T> void write_int(T a) { if (!a) { putchar_unlocked('0'); putchar_unlocked('\n'); return; } if (a < 0) putchar_unlocked('-'), a *= -1; char s[37]; int now = 37; while (a) { s[--now] = (char)'0' + a % 10; a /= 10; } while (now < 37) putchar_unlocked(s[now++]); } template <typename T> constexpr inline void putint(T a) { if (!a) { putchar_unlocked('0'); putchar_unlocked('\n'); return; } if (a < 0) putchar_unlocked('-'), a *= -1; char s[37]; int now = 37; while (a) { s[--now] = (char)'0' + a % 10; a /= 10; } while (now < 37) putchar_unlocked(s[now++]); putchar_unlocked('\n'); } template <typename Head, typename... Tail> constexpr inline void putint(Head head, Tail... tail) { putint(head); putint(tail...); } /** * 文字列の入出力 */ void readstr(std::string& str) { char c = getchar_unlocked(); while (isspace(c)) c = getchar_unlocked(); while (!isspace(c)) { str += c; c = getchar_unlocked(); } } void putstr(const std::string& str) { for (auto c : str) { putchar_unlocked(c); } putchar_unlocked('\n'); } }; // namespace kyopro /** * @brief fastIO */ #line 2 "library/src/template.hpp" #include <bits/stdc++.h> #define rep(i, N) for (int i = 0; i < (N); i++) #define all(x) (x).begin(), (x).end() #define popcount(x) __builtin_popcountll(x) using i128 = __int128_t; using ll = long long; using ld = long double; using graph = std::vector<std::vector<int>>; using P = std::pair<int, int>; constexpr int inf = 1e9; constexpr ll infl = 1e18; constexpr ld eps = 1e-6; const long double pi = acos(-1); constexpr uint64_t MOD = 1e9 + 7; constexpr uint64_t MOD2 = 998244353; constexpr int dx[] = {1, 0, -1, 0}; constexpr int dy[] = {0, 1, 0, -1}; template <typename T1, typename T2> constexpr inline bool chmax(T1& a, T2 b) { return a < b && (a = b, true); } template <typename T1, typename T2> constexpr inline bool chmin(T1& a, T2 b) { return a > b && (a = b, true); } #line 4 "main.cpp" #define debug(x) \ std::cout << #x << " : "; \ for (auto __ : x) std::cout << __.val() << ' '; \ std::cout << std::endl; using namespace std; using namespace atcoder; using namespace kyopro; using mint = atcoder::modint998244353; int main() { int p; readint(p); int g = atcoder::internal::primitive_root_constexpr(p); // putint(g); vector<mint> a(p), b(p); for (int i = 1; i < p; ++i) readint(a[i]); for (int i = 1; i < p; ++i) readint(b[i]); vector<mint> ap(p - 1), bp(p - 1); vector<int> pow(p); { for (int e = 0, pw = 1; e <= p; ++e) { pow[e] = pw; pw = (ll)pw * g % p; } } for (int i = 0; i < p - 1; ++i) { ap[i] = a[pow[i]]; bp[i] = b[pow[i]]; } // debug(ap) debug(bp); vector<mint> cp = convolution(ap, bp); // debug(cp); vector<mint> c(p); for (int i = p - 1; i < (int)cp.size(); ++i) { cp[i - p + 1] += cp[i]; } // debug(cp); for (int i = 0; i < p - 1; ++i) { c[pow[i]] = cp[i]; } // debug(c); for (int i = 1; i < p; ++i) putint(c[i].val()); }