Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <iomanip>
  4. #include <map>
  5. #include <set>
  6. #include <string>
  7. #include <queue>
  8. #include <algorithm>
  9. #include <fstream>
  10. #include <math.h>
  11. #include <cmath>
  12.  
  13. using namespace std;
  14. using ll=long long;
  15.  
  16. ll gcd(ll a, ll b) {
  17. if (b == 0)
  18. return a;
  19. else
  20. return gcd(b, a % b);
  21. }
  22.  
  23. int main()
  24. {
  25. ifstream cin("input.txt");
  26. ios::sync_with_stdio(false);
  27. cin.tie(nullptr);
  28. cout.tie(nullptr);
  29. int n;
  30. cin >> n;
  31. vector <vector<int>> arr(n, vector<int>(n, 0));
  32. for (int i = 0; i < n; i++)
  33. {
  34. for (int j = 0; j < n; j++)
  35. {
  36. cin >> arr[i][j];
  37. }
  38. }
  39. ll gc = 0;
  40. gc = gcd(arr[0][1], arr[0][2]);
  41. for (int i = 3; i < n; i++)
  42. {
  43. gc = gcd(gc, arr[0][i]);
  44. }
  45. cout << gc << " ";
  46. for (int i = 1; i < n; i++)
  47. {
  48. cout << arr[0][i] / gc<<" ";
  49. }
  50. return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement