Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <sstream>
- #include <cstdlib>
- #include <algorithm>
- #include <cmath>
- #include <iomanip>
- #include <numeric>
- #include <vector>
- #include <string>
- #include <set>
- #include <map>
- #include <stack>
- #include <deque>
- #include <unordered_map>
- #include <bits/stdc++.h>
- #include <queue>
- using namespace std;
- #define ll long long
- void sherry()
- {
- ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
- #endif
- }
- bool comp(pair<int, int> a, pair<int, int> b)
- {
- return a.second > b.second;
- }
- ll fac(ll t)
- {
- if (t == 1)
- {
- return 1;
- }
- return t * fac(t - 1);
- }
- ll gcd(ll a, ll b)
- {
- return b == 0 ? a : gcd(b, a % b);
- }
- int main()
- {
- sherry();
- // freopen("equal.in", "r", stdin);
- ll t;
- cin >> t;
- while (t--)
- {
- ll n, sum = 0;
- ll p;
- cin >> n;
- for (ll i = 0; i < n; i++)
- {
- ll num;
- cin >> num;
- sum += num;
- if (i == 0)
- p = num;
- else
- p = gcd(p, num);
- }
- cout << sum << " " << p << "\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement