Advertisement
Pearlfromsu

ррр

May 15th, 2024
730
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.45 KB | None | 0 0
  1. /******************************************************************************
  2.  
  3.                               Online C++ Compiler.
  4.                Code, Compile, Run and Debug C++ program online.
  5. Write your code in this editor and press "Run" button to compile and execute it.
  6.  
  7. *******************************************************************************/
  8.  
  9. #include <iostream>
  10. #include <algorithm>
  11. using namespace std;
  12. int res[1000][100];
  13. int ish[130];
  14. int main()
  15. {
  16.     cout << "Размер вектора(альфа = ..x^0 + ..x^1 + ...):\n";
  17.     int n;
  18.     cin >> n;
  19.     cout << "вектор альфа = ..x^0 + ..x^1 + ... :\n";
  20.     for(int i = 0; i < n; i++)
  21.         cin >> ish[i];
  22.    
  23.     cout << "харка x поля Z_x(модуль):\n";
  24.     int mod;
  25.     cin >> mod;
  26.     for(int i = 0; i < n; i++) {
  27.         res[i][i] = 1;
  28.     }
  29.     for(int i = 0; i < 130; i++)
  30.         res[n][i] = ish[i];
  31.        
  32.    
  33.     for(int i = n+1; i < 130; i++) {
  34.         for(int j = 1; j < 130; j++) {
  35.             res[i][j] = res[i-1][j-1];
  36.         }
  37.         int mult = res[i][n];
  38.         res[i][n] = 0;
  39.         for(int j = 0; j < n; j++) {
  40.             res[i][j] = (res[i][j] + mult*res[n][j])%mod;
  41.         }
  42.     }
  43.    
  44.     for(int i = 0; i < 130; i++) {
  45.         cout << "#" << i << ": ";
  46.         for(int j = 0; j < n+2; j++) {
  47.             cout << res[i][j] << ' ';
  48.         }
  49.         cout << '\n';
  50.     }
  51.    
  52.    
  53.     return 0;
  54. }
  55.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement