fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <queue> //priority queue
  4. #include <stack>
  5. #include <map> // multimap
  6. #include <set> //multiset
  7. #include <list>
  8. #include <utility> // pair
  9. #include <iterator>
  10. #include <deque> // insertion as both ends
  11. #include <string>
  12. // g1=s.substr(0,n/2);
  13. // g2=s.substr(n/2+n%2,n/2);
  14. #include <cctype> //isaplha
  15. #include <iomanip> // std::setprecision
  16. #include <algorithm> //binary_search,sort, next_permutation in lexicographically greater permutation
  17. #include <cmath>
  18. #include <limits.h> //INT_MIN,INT_MAX
  19. #include <numeric> //iota,partial_sum,inner_product,accumulate(begin,end,num)
  20. #include <functional> //Arithmetic, comparators, logical
  21. #include <bitset>
  22. #define rep(i,a,b) for(int i=a;i<b;i++)
  23. #define rrep(i,b,a) for(int i=b-1;i>=a;i--)
  24. #define fori(a) for(auto i : a )
  25. #define all(a) begin(a), end(a)
  26. #define set(a,b) memset(a,b,sizeof(a))
  27.  
  28. #define ll long long
  29. #define pb push_back
  30. #define PF push_front //deque
  31. #define mp make_pair
  32. #define pq priority_queue
  33. #define mod 1000000007
  34. #define f first
  35. #define s second
  36. #define pii pair< int, int >
  37. #define tc int t; cin >> t; while(t--)
  38.  
  39. using namespace std;
  40. string repeat(string s, int n) {
  41. string s1 = s;
  42. for (int i=1; i<n;i++)
  43. s += s1;
  44. return s;
  45. }
  46. string getString(char x) {
  47. string s(1, x);
  48. return s;
  49. }
  50.  
  51. void optimizeIO(){
  52. ios_base::sync_with_stdio(false);
  53. cin.tie(NULL);
  54. cout.tie(NULL);
  55. }
  56. int main(){
  57. optimizeIO();
  58. int n;
  59. cin>>n;
  60. int a[n],b[n];
  61. rep(i,0,n) {cin>>a[i]; b[i]=a[i];}
  62. int max_=*max_element(a,a+n);
  63. rep(i,0,n){
  64. b[i]=max_-b[i];
  65. }
  66. int i=0,ans;
  67. for(;i<n;i++){
  68. if(b[i]!=0){
  69. ans=b[i];
  70. break;
  71. }
  72. }
  73. for(;i<n;i++){
  74. if(b[i]!=0){
  75. ans= __gcd(ans,b[i]);
  76. }
  77. }
  78. ll sword=0;
  79. rep(i,0,n){
  80. sword+=(b[i]/ans);
  81. }
  82. cout<<sword<<" "<<ans<<endl;
  83. return 0;
  84. }
Success #stdin #stdout 0s 4444KB
stdin
6
13 52 0 13 26 52
stdout
12 13