fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int gcd(int a, int b) {
  4. return (b>0 ? gcd(b, a%b) : a);
  5. }
  6. int main() {
  7. int x, y, l, r;
  8. cin >> l >> r >> x >> y;
  9. long long p = x * y, sqrtP = sqrt(p);
  10. int res = 0;
  11. for(int i=1; i <= sqrtP; i++) {
  12. if (p % i == 0) {
  13. int a = i, b = p / i;
  14. if( l <= a && a <= r && l <= b && b <= r && gcd(a, b) == x)
  15. res += 2;
  16. }
  17. }
  18. if(sqrtP * sqrtP == p && l <= sqrtP && sqrtP <= r)
  19. res--;
  20. cout << res << endl;
  21. return 0;
  22. }
Success #stdin #stdout 0s 4532KB
stdin
50 100 3 30
stdout
0