[JAVA] ABC --010 --A & B & C

AtCoder ABC 010 A&B&C AtCoder - 010

A --Handle name

	private void solveA() {
		out.println(next() + "pp");
	}

B-Flower fortune-telling

――I tried to branch at first, but when I thought about it, it was easier to read if I branched at the remainder of 6, which is the least common multiple of 2 and 3. --The if statement that is commented out is also AC

	private void solveB() {
		int n = nextInt();
		int[] wk = IntStream.range(0, n).map(i -> nextInt()).toArray();
		int res = Arrays.stream(wk).reduce(0, (sum, i) -> {
			switch (i % 6) {
			case 1:
				return sum;
			case 2:
				return ++sum;
			case 3:
				return sum;
			case 4:
				return ++sum;
			case 5:
				return sum += 2;
			case 0:
				return sum += 3;
			}
			//			if (i % 2 == 1) {
			//				switch (i % 3) {
			//				case 0:
			//				case 1:
			//					return sum;
			//				case 2:
			//					return sum += 2;
			//				}
			//
			//			} else {
			//				switch (i % 3) {
			//				case 0:
			//					return sum += 3;
			//				case 1:
			//				case 2:
			//					return ++sum;
			//				}
			//			}

			return sum;
		});

		out.println(res);
	}

C-Cheating investigation

--I saw the three-square theorem for the first time in a long time ――If you look at the solution after thinking that it will pass even if you push it hard, you can solve it with the ellipse theorem. .. .. I do not understand. .. ..

	private void solveC() {
		int sX = nextInt();
		int sY = nextInt();
		int gX = nextInt();
		int gY = nextInt();
		int t = nextInt();
		int v = nextInt();
		int n = nextInt();

		for (int i = 0; i < n; i++) {
			int tmpX = nextInt();
			int tmpY = nextInt();
			double total = (Math.hypot(Math.abs(tmpX - sX), Math.abs(tmpY - sY))
					+ Math.hypot(Math.abs(tmpX - gX), Math.abs(tmpY - gY)));
			if (total <= t * v) {
				out.println("YES");
				return;
			}
		}

		out.println("NO");
	}

Recommended Posts

ABC --013-A & B & C
ABC --023 --A & B & C
ABC --036-A & B & C
ABC --010 --A & B & C
ABC --028 --A & B & C
ABC --015 --A & B & C
ABC --128 --A & B & C
ABC --012-A & B & C
ABC --018 --A & B & C
ABC --054 --A & B & C
ABC --017 --A & B & C
ABC --029- A & B & C
ABC --022 --A & B & C
ABC --019 --A & B & C
ABC --020 --A & B & C
ABC --030- A & B & C
ABC --127 --A & B & C
ABC --007 --A & B & C
ABC --132- A & B & C
ABC --026 --A & B & C
ABC --014- A & B & C
ABC --016 --A & B & C
ABC --011-A & B & C
ABC --031 --A & B & C
ABC --021 --A & B & C
ABC --025 --A & B & C
ABC --024 --A & B & C
ABC --027 --A & B & C
ABC --080- A & B & C
ABC --129- A & B & C & D
ABC --133- A & B & C & D
ABC --122 --A & B & C & D
ABC --125- A & B & C & D
ABC --130- A & B & C & D
ABC --126 --A & B & C & D
ABC --134- A & B & C & D & E
ABC --131- A & B & C & D & E
diverta 2019 Programming Contest A & B & C & D
AtCoder Beginner Contest 169 A, B, C with ruby
atcoder ABC113 C problem
ABC093 C --Same Integers
atcoder ABC115 C problem
AtCoder Beginner Contest 170 A, B, C up to ruby
A person writing C ++ tried writing Java
Make a SOAP call in C #
Call a C function from Swift
NLP4J [006-034] 100 language processing knocks with NLP4J # 34 "A B"