Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. package com.hacker.earth;
  2.  
  3. import java.util.Arrays;
  4. import java.util.Scanner;
  5. import java.util.stream.Collectors;
  6.  
  7. public class RoyAndBulbs {
  8.  
  9.  
  10. public static void main(String args[]) {
  11. // Scanner
  12. Scanner s = new Scanner(System.in);
  13.  
  14. String[] data = s.nextLine().split(" ");
  15. int T = Integer.valueOf(data[0]);
  16. int R = Integer.valueOf(data[1]);
  17. int G = Integer.valueOf(data[2]);
  18. int B = Integer.valueOf(data[3]);
  19.  
  20. int[] output = new int[8];
  21.  
  22. for (int i = 0; i < T; i++) {
  23. int red = 0;
  24. if ((i / R) % 2 == 1) {
  25. red = 1;
  26. }
  27.  
  28. int blue = 0;
  29. if ((i / B) % 2 == 1) {
  30. blue = 1;
  31. }
  32. int green = 0;
  33. if ((i / G) % 2 == 1) {
  34. green = 1;
  35. }
  36.  
  37. if (red == 1 && green == 0 && blue == 0) {
  38. output[0]++;
  39. }
  40. if (red == 0 && green == 1 && blue == 0) {
  41. output[1]++;
  42. }
  43. if (red == 0 && green == 0 && blue == 1) {
  44. output[2]++;
  45. }
  46. if (red == 1 && green == 1 && blue == 0) {
  47. output[3]++;
  48. }
  49. if (red == 0 && green == 1 && blue == 1) {
  50. output[4]++;
  51. }
  52. if (red == 1 && green == 0 && blue == 1) {
  53. output[5]++;
  54. }
  55. if (red == 1 && green == 1 && blue == 1) {
  56. output[6]++;
  57. }
  58. if (red == 0 && green == 0 && blue == 0) {
  59. output[7]++;
  60. }
  61. }
  62.  
  63. System.out.println(Arrays.stream(output).mapToObj(String::valueOf).collect(Collectors.joining(" ")));
  64.  
  65. }
  66.  
  67.  
  68.  
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement