Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <iomanip>
- #include <map>
- #include <set>
- #include <string>
- #include <queue>
- #include <algorithm>
- #include <fstream>
- #include <math.h>
- #include <cmath>
- using namespace std;
- using ll=long long;
- ll gcd(ll a, ll b) {
- if (b == 0)
- return a;
- else
- return gcd(b, a % b);
- }
- int main()
- {
- ifstream cin("input.txt");
- ios::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- int n;
- cin >> n;
- vector <vector<int>> arr(n, vector<int>(n, 0));
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < n; j++)
- {
- cin >> arr[i][j];
- }
- }
- ll gc = 0;
- gc = gcd(arr[0][1], arr[0][2]);
- for (int i = 3; i < n; i++)
- {
- gc = gcd(gc, arr[0][i]);
- }
- cout << gc << " ";
- for (int i = 1; i < n; i++)
- {
- cout << arr[0][i] / gc<<" ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement