fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. ios::sync_with_stdio(false);
  6. int total, s;
  7. cin >> total>>s;
  8.  
  9. int cnt = 0;
  10. int t =0;
  11. int mybus = 0;
  12. int bus = 0;
  13. int emp =0;
  14. while (total!=0)
  15. {
  16. int m = 45;
  17. m = m-s;
  18. cnt++;
  19. s = s - 45;
  20. if(s <= 0 && t == 0){ mybus = cnt;t = 1;}
  21. // if(total>s ) mybus++;
  22.  
  23. emp = 45;
  24. emp = emp - total;
  25. total = total - 45;
  26. if(total<0) total = 0;
  27. bus++;
  28.  
  29.  
  30. }
  31. if(total>s) mybus -1;
  32. cout << bus <<' '<<mybus<<' '<<emp<<endl;
  33. }
Success #stdin #stdout 0.01s 5320KB
stdin
901 622
stdout
21 14 44