fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main(){
  4. ios_base::sync_with_stdio(0);
  5. cin.tie(0);
  6. int i,j;
  7. int totalweight;
  8. cin>>totalweight;
  9. int five,three,other = 0;
  10. if(totalweight>=5){
  11. five = totalweight/5;
  12. other = totalweight%5;
  13. }else{
  14. five = 0;
  15. other = totalweight;
  16. }
  17. if(other%3!=0){
  18. cout<<-1;
  19. }
  20. else{
  21. three = other/3;
  22. cout<<five+three;
  23. }
  24. return 0;
  25. }
Success #stdin #stdout 0s 5504KB
stdin
18
stdout
4