fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. ios::sync_with_stdio(false);
  6. cin.tie(NULL);
  7.  
  8. int t;
  9. cin >> t;
  10. while (t--) {
  11. long long l, a, b;
  12. cin >> l >> a >> b;
  13. long long g = __gcd(l, b);
  14. cout << l - g + a << '\n';
  15. }
  16. return 0;
  17. }
  18.  
Success #stdin #stdout 0.01s 5288KB
stdin
4
5 3 2
2 0 6
8 2 4
100 0 1
stdout
7
0
6
99