fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. using ll = long long;
  4. ll x;
  5. bool uoca(long long x, long long a) {
  6. if (x == 0) return false;
  7. return (a % x == 0);
  8. }
  9. bool uocb(long long x , long long b){
  10. if ( x == 0) return false;
  11. return ( b % (3*x) == 0);
  12. }
  13. int main(){
  14. ios::sync_with_stdio(false);
  15. cin.tie(nullptr);
  16. // freopen("TONGUOC.INP" , "r" , stdin);
  17. // freopen("TONGUOC.OUT" , "w" , stdout);
  18. ll a , b;
  19. cin >> a >> b;
  20. ll s = 0;
  21. for( int x =1 ; x * 3 <= b && x <= a ; x++ ){
  22. if( uoca(x,a) && uocb(x,b) ) s+=x;
  23. }
  24. cout << s;
  25. return 0;
  26.  
  27. }
  28.  
Success #stdin #stdout 0.01s 5276KB
stdin
4 18
stdout
3