fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long ll;
  5.  
  6. signed main(){
  7.  
  8. ios_base::sync_with_stdio(false);
  9. cin.tie(0);
  10.  
  11. int t;
  12. cin >> t;
  13.  
  14. while(t--){
  15. ll n, x, y;
  16. cin >> n >> x >> y;
  17. ll k = (x * y) / __gcd(x, y);
  18. ll chung = n / k;
  19. ll mx = n / x - chung;
  20. ll my = n / y - chung;
  21.  
  22. ll a = (n + n - mx + 1) * mx / 2;
  23. ll b = (1 + my) * my / 2;
  24. cout << a - b << '\n';
  25.  
  26. }
  27.  
  28. return 0;
  29. }
  30.  
Success #stdin #stdout 0s 5304KB
stdin
Standard input is empty
stdout
Standard output is empty