fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int n, answer=1001, sum, count;
  5. scanf("%d", &n);
  6.  
  7. for (int i=0;i*5<=n;i++){
  8. sum = i*5;
  9. count = i;
  10. while (sum<n){
  11. sum += 3;
  12. count++;
  13. }
  14. if (sum == n){
  15. if (answer > count){
  16. answer = count;
  17. }
  18. }
  19. }
  20. if (answer == 1001){
  21. answer = -1;
  22. }
  23. printf("%d", answer);
  24. }
Success #stdin #stdout 0s 5304KB
stdin
4999
stdout
-1