fork(3) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long int
  4. void solution(ll a, ll b, ll n)
  5. {
  6. for (ll i = 0; i * a <= n; i++)
  7. {
  8. if ((n - (i * a)) % b == 0) {
  9. cout<< (n - (i * a)) / b<<" ";
  10. return;
  11. }
  12. }
  13. }
  14. int main()
  15. {
  16. ll t;
  17. cin>>t;
  18. while(t--)
  19. {
  20. ll a ,b,n;
  21. cin>>n>>a>>b;
  22. a=a*-1;
  23. solution(a, b, n);
  24. }
  25. return 0;
  26. }
Success #stdin #stdout 0s 4412KB
stdin
2 9 5 12 5 7 9
stdout
2 6