fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. unsigned long long int a, b, x, y;
  6.  
  7. int main()
  8. {
  9. cin >> a >> b;
  10. do
  11. {
  12. cin >> x >> y;
  13. int j=0;
  14. for (int i=x; i<=y; i++)
  15. {
  16. if (i%a==0 || i%b==0)
  17. j++;
  18. }
  19. cout << j << endl;
  20.  
  21. }while(!cin.eof());
  22. return 0;
  23. }
Success #stdin #stdout 0s 3472KB
stdin
3 5
1 2
1 3
3 5
1 100
stdout
0
1
2
47
47