Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int main()
- {
- int N, M, MOD;
- cin >> N >> M >> MOD;
- vector <int> a(N + 1);
- for (int i = 0; i <= N; i++) cin >> a[i];
- int x;
- long long pol;
- for (int i = 0; i < M; i++) {
- cin >> x;
- pol = a[0] % MOD;
- for (int j = 1; j <= N; j++)
- pol = (pol * x + a[j]) % MOD;
- pol %= MOD;
- cout << pol << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment