JuliaMelkozerova

HW1D

Mar 14th, 2020
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int N, M, MOD;
  9.     cin >> N >> M >> MOD;
  10.    
  11.     vector <int> a(N + 1);
  12.     for (int i = 0; i <= N; i++) cin >> a[i];
  13.    
  14.     int x;
  15.     long long pol;
  16.     for (int i = 0; i < M; i++) {
  17.         cin >> x;
  18.         pol = a[0] % MOD;
  19.         for (int j = 1; j <= N; j++)
  20.             pol = (pol * x + a[j]) % MOD;
  21.         pol %= MOD;
  22.         cout << pol << endl;
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment