daily pastebin goal
5%
SHARE
TWEET

Untitled

a guest Sep 19th, 2018 68 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define ll long long;
  6. const int scz = 1e9;
  7.  
  8. int main()
  9. {
  10.     freopen ("mcd.in", "r", stdin);
  11.     freopen ("mcd.out", "w", stdout);
  12.     int a, b;
  13.     cin >> a >> b;
  14.     int ans, sum = 0;
  15.     for (int i = 1; i <= a; i++)
  16.     {
  17.         if (a % i == 0 && b % i == 0)
  18.         {
  19.             int q = 0, w = i;
  20.             while (w > 0)
  21.             {
  22.                 q += w % 10;
  23.                 w /= 10;
  24.             }
  25.             if (q > sum)
  26.             {
  27.                 ans = i;
  28.                 sum = q;
  29.             }
  30.         }
  31.     }
  32.     cout << ans;
  33. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top