fork download
  1. #include<iostream>
  2. #include<cmath>
  3. using namespace std;
  4. int main()
  5. {
  6. ios_base::sync_with_stdio(0);
  7. cin.tie(0);
  8. cout.tie(0);
  9. int n , a , b;
  10. cin >> n >> a >> b;
  11. while(n > a && n > b)
  12. {
  13. n = n %( a + 2 * b);
  14. if( n > b )
  15. {
  16. n = n % b;
  17. }
  18. else if (n > a)
  19. {
  20. n = n % a;
  21. }
  22. }
  23. cout << n;
  24. return 0;
  25. }
Success #stdin #stdout 0.01s 5472KB
stdin
Standard input is empty
stdout
22064