fork download
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4. private static Scanner sc;
  5.  
  6. public static void main(String[] args) {
  7. int j;
  8. Scanner st = new Scanner(System.in);
  9. int cs = st.nextInt();
  10. int a = 0;
  11. int temp = 0;
  12. while (a < cs) {
  13. int i = st.nextInt();
  14. j = freeBottle(i);
  15. a++;
  16. free = 0;
  17. System.out.println(j);
  18. }
  19. }
  20.  
  21. static int free;
  22.  
  23. static int freeBottle(int i) {
  24. int temp = 0;
  25. while (i >= 3) {
  26. temp++;
  27. i = i - 3;
  28. }
  29. free = free + temp;
  30. int p = temp + i;
  31. if (p > 2) {
  32. freeBottle((temp + i));
  33. }
  34. if (p == 2) {
  35. free++;
  36. }
  37. return free;
  38. }
  39. }
  40.  
Success #stdin #stdout 0.11s 380672KB
stdin
3
10
81
0
stdout
5
40
0