Skip to content

Adding polynomial mini-library #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 10, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update polynomial.cpp
  • Loading branch information
adamant-pwn authored Mar 8, 2019
commit e691217e6b203c54c1f5c52da5e5f0b96a080c86
40 changes: 20 additions & 20 deletions src/polynomial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,24 +404,24 @@ namespace algebra {
using namespace algebra;

signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
int k, n;
cin >> k >> n;
vector<base> a(k), c(k);
for(int i = 0; i < k; i++) {
cin >> a[i];
}
for(int i = 0; i < k; i++) {
cin >> c[i];
}
reverse(begin(c), end(c));
polyn chara = xk(k) - polyn{c};
polyn b = bpow(xk(1), n - 1, chara);
base ans = 0;
for(int i = 0; i < k; i++) {
ans += b[i] * a[i];
}
cout << ans << endl;
return 0;
ios::sync_with_stdio(0);
cin.tie(0);
int k, n;
cin >> k >> n;
vector<base> a(k), c(k);
for(int i = 0; i < k; i++) {
cin >> a[i];
}
for(int i = 0; i < k; i++) {
cin >> c[i];
}
reverse(begin(c), end(c));
polyn chara = xk(k) - polyn{c};
polyn b = bpow(xk(1), n - 1, chara);
base ans = 0;
for(int i = 0; i < k; i++) {
ans += b[i] * a[i];
}
cout << ans << endl;
return 0;
}