Advertisement
sherry_ahmos

Untitled

May 11th, 2022
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.26 KB | None | 0 0
  1. #include <iostream>
  2. #include <sstream>
  3. #include <cstdlib>
  4. #include <algorithm>
  5. #include <cmath>
  6. #include <iomanip>
  7. #include <numeric>
  8. #include <vector>
  9. #include <string>
  10. #include <set>
  11. #include <map>
  12. #include <stack>
  13. #include <deque>
  14. #include <unordered_map>
  15. #include <bits/stdc++.h>
  16. #include <queue>
  17.  
  18. using namespace std;
  19. #define ll long long
  20. void sherry()
  21. {
  22.     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  23. #ifndef ONLINE_JUDGE
  24.     freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  25. #endif
  26. }
  27. bool comp(pair<int, int> a, pair<int, int> b)
  28. {
  29.     return a.second > b.second;
  30. }
  31. ll fac(ll t)
  32. {
  33.     if (t == 1)
  34.     {
  35.         return 1;
  36.     }
  37.     return t * fac(t - 1);
  38. }
  39. ll gcd(ll a, ll b)
  40. {
  41.     return b == 0 ? a : gcd(b, a % b);
  42. }
  43. int main()
  44. {
  45.     sherry();
  46.     // freopen("equal.in", "r", stdin);
  47.     ll t;
  48.     cin >> t;
  49.     while (t--)
  50.     {
  51.         ll n, sum = 0;
  52.         ll p;
  53.         cin >> n;
  54.         for (ll i = 0; i < n; i++)
  55.         {
  56.             ll num;
  57.             cin >> num;
  58.             sum += num;
  59.             if (i == 0)
  60.                 p = num;
  61.             else
  62.                 p = gcd(p, num);
  63.         }
  64.         cout << sum << " " << p << "\n";
  65.     }
  66.     return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement