0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ABC - 042- A&B&C

Posted at

AtCoder ABC 042 A&B&C

AtCoder - 042

A問題

  • 5が2個
  • 7が1個
	private void solveA() {
		int n5 = 0;
		int n7 = 0;
		for (int i = 0; i < 3; i++) {
			if (nextInt() == 5) {
				n5++;
			} else {
				n7++;
			}
		}

		out.println(n5 == 2 && n7 == 1 ? "YES" : "NO");
	}

B問題

  • 文字列ソートして結合
	private void solveB() {
		int numN = nextInt();
		int numL = nextInt();
		String[] wk = IntStream.range(0, numN).collect(() -> new String[numN],
				(t, i) -> {
					t[i] = next();
				},
				(t, u) -> {
					Stream.concat(Arrays.stream(t), Arrays.stream(u));
				});

		Arrays.sort(wk);

		String builder = Arrays.stream(wk).reduce("",
				(sum, i) -> {
					sum += i;
					return sum;
				});

		out.println(builder);
	}

C問題

  • N以上の数値を条件に合致するかを判定し、条件に合致したら出力して終了
    • setを使っているのは条件判定をcontainsで行いたかったから
	private void solveC() {
		int numN = nextInt();
		int numK = nextInt();

		Set<String> notUseSet = IntStream.range(0, numK).mapToObj(i -> next()).collect(
				() -> new HashSet<String>(),
				(t, i) -> {
					t.add(i);
				},
				(t, u) -> {
					t.addAll(u);
				});

		int j = numN;

		while (true) {
			String[] wk = Integer.toString(j).split("");
			boolean isRes = true;

			for (String c : wk) {
				if (notUseSet.contains(c)) {
					isRes = false;
					break;
				}
			}
			if (isRes) {
				out.println(j);
				break;
			}
			j++;
		}

	}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?