-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c6a5e57
commit f399599
Showing
4 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// @brief Polynomial Interpolation (Geometric Sequence) | ||
#define PROBLEM "https://judge.yosupo.jp/problem/polynomial_interpolation_on_geometric_sequence" | ||
#pragma GCC optimize("Ofast,unroll-loops") | ||
#include "cp-algo/math/poly.hpp" | ||
#include <bits/stdc++.h> | ||
|
||
using namespace std; | ||
using namespace cp_algo::math; | ||
|
||
const int mod = 998244353; | ||
using base = modint<mod>; | ||
using polyn = poly_t<base>; | ||
|
||
void solve() { | ||
int n, a, r; | ||
cin >> n >> a >> r; | ||
vector<base> y(n); | ||
copy_n(istream_iterator<base>(cin), n, begin(y)); | ||
polyn(y).chirpz_inverse(r, n).mulx(base(a).inv()).print(n); | ||
} | ||
|
||
signed main() { | ||
//freopen("input.txt", "r", stdin); | ||
ios::sync_with_stdio(0); | ||
cin.tie(0); | ||
int t = 1; | ||
while(t--) { | ||
solve(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// @brief Multipoint Evaluation | ||
#define PROBLEM "https://judge.yosupo.jp/problem/multipoint_evaluation" | ||
#pragma GCC optimize("Ofast,unroll-loops") | ||
#include "cp-algo/math/poly.hpp" | ||
#include <bits/stdc++.h> | ||
|
||
using namespace std; | ||
using namespace cp_algo::math; | ||
|
||
const int mod = 998244353; | ||
using base = modint<mod>; | ||
using polyn = poly_t<base>; | ||
|
||
void solve() { | ||
int n, m; | ||
cin >> n >> m; | ||
vector<base> f(n), x(m); | ||
copy_n(istream_iterator<base>(cin), n, begin(f)); | ||
copy_n(istream_iterator<base>(cin), m, begin(x)); | ||
polyn(polyn(f).eval(x)).print(m); | ||
} | ||
|
||
signed main() { | ||
//freopen("input.txt", "r", stdin); | ||
ios::sync_with_stdio(0); | ||
cin.tie(0); | ||
int t = 1; | ||
while(t--) { | ||
solve(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// @brief Multipoint Evaluation (Geometric Sequence) | ||
#define PROBLEM "https://judge.yosupo.jp/problem/multipoint_evaluation_on_geometric_sequence" | ||
#pragma GCC optimize("Ofast,unroll-loops") | ||
#include "cp-algo/math/poly.hpp" | ||
#include <bits/stdc++.h> | ||
|
||
using namespace std; | ||
using namespace cp_algo::math; | ||
|
||
const int mod = 998244353; | ||
using base = modint<mod>; | ||
using polyn = poly_t<base>; | ||
|
||
void solve() { | ||
int n, m, a, r; | ||
cin >> n >> m >> a >> r; | ||
vector<base> f(n); | ||
copy_n(istream_iterator<base>(cin), n, begin(f)); | ||
polyn(f).mulx(a).chirpz(r, m).print(m); | ||
} | ||
|
||
signed main() { | ||
//freopen("input.txt", "r", stdin); | ||
ios::sync_with_stdio(0); | ||
cin.tie(0); | ||
int t = 1; | ||
while(t--) { | ||
solve(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// @brief Shift of Sampling Points of Polynomial | ||
#define PROBLEM "https://judge.yosupo.jp/problem/shift_of_sampling_points_of_polynomial" | ||
#define CP_ALGO_MAXN 1 << 20 | ||
#pragma GCC optimize("Ofast,unroll-loops") | ||
#include "cp-algo/math/poly.hpp" | ||
#include <bits/stdc++.h> | ||
|
||
using namespace std; | ||
using namespace cp_algo::math; | ||
|
||
const int mod = 998244353; | ||
using base = modint<mod>; | ||
using polyn = poly_t<base>; | ||
|
||
// TODO: Use single-convolution approach | ||
void solve() { | ||
int n, m, c; | ||
cin >> n >> m >> c; | ||
vector<base> a(n); | ||
copy_n(istream_iterator<base>(cin), n, begin(a)); | ||
polyn A = polyn(a); | ||
polyn Q = polyn({1, -1}).pow(n, n + 1); | ||
A -= ((A * Q).div_xk(n).mod_xk(m) * Q.inv(m)).mod_xk(m).mul_xk(n); | ||
A = A.reverse(n + m); | ||
polyn shift = polyn({1, -1}).pow(c, n).shift(1).mulx(-1); | ||
auto R = (A.div_xk(n - 1) * shift) + (A.mod_xk(n - 1) * shift).div_xk(n - 1); | ||
R.div_xk(1).reverse(m).print(m); | ||
} | ||
|
||
signed main() { | ||
//freopen("input.txt", "r", stdin); | ||
ios::sync_with_stdio(0); | ||
cin.tie(0); | ||
int t; | ||
t = 1;// cin >> t; | ||
while(t--) { | ||
solve(); | ||
} | ||
} |