fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int k, t, a=0, dv=1;
  7. cin >> k >> t;
  8. while (t > 0)
  9. {
  10. a=a+dv;
  11. if((a==k)||(a==0))
  12. dv=-dv;
  13. t=t-1;
  14. }
  15. cout << a;
  16. return 0;
  17. }
Success #stdin #stdout 0s 4300KB
stdin
Standard input is empty
stdout
32765