[JAVA] ABC - 134 - A & B & C & D & E.

AtCoder ABC 134 A&B&C&D&E AtCoder - 134

E / F hat keine Zeit mehr ...

A - Dodecagon

	private void solveA() {
		int n = nextInt();
 
		out.println(3 * n * n);
	}

B - Golden Apple


	/**
	 * 6 2
	 * 1 2 3 4 5 6
	 * - - ^ - -
	 *   - - ^ - -
	 *
	 * 20 4
	 * 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20
	 *  -  -  -  -  ^  -  -  -  -
	 *                             -  -  -  -  ^  -  -  -  -
	 *                                   -  -  -  -  ^  -  -  -  -
	 */
	private void solveB() {
		int n = nextInt();
		int d = nextInt();
		int d2 = 2 * d + 1;
		int res = (n / d2) + ((n % d2) != 0 ? 1 : 0);
		out.println(res);
	}

C - Exception Handling

Der Maximalwert oder der zweitgrößte Wert sollte ausgegeben werden. Ich habe die Sequenz kopiert und geantwortet. .. ..


	private void solveC() {
		int n = nextInt();
		int[] wk = IntStream.range(0, n).map(i -> nextInt()).toArray();
		int[] copy = Arrays.copyOf(wk, n);
		Arrays.sort(copy);
		int max = copy[n - 1];
		for (int i : wk) {
			if (i < max)
				out.println(max);
			else
				out.println(copy[n - 2]);
		}
	}

D - Preparing Boxes

Anfangs sind keine Bälle in allen Kisten. Gerade oder Ungerade sollten für jede Zahl übereinstimmen. Es scheint schwierig, sich von vorne zu entscheiden. Warum also nicht von hinten entscheiden? Implementiert das zu denken. Von hinten ist es leicht zu bestimmen, da es numerische Werte gibt, die keine Vielfachen haben. In Beispiel 1 wird beispielsweise zuerst der dritte Wert bestimmt. Das dritte Vielfache 6 existiert nicht, daher kann es bestimmt werden. Wenn Sie sich von Anfang an entscheiden, können Sie sich dann nicht für 1,2,3 ... entscheiden? Gefühl.


	private void solveD() {
		int n = nextInt();
		int[] wk = IntStream.range(0, n).map(i -> nextInt()).toArray();
 
		int cnt = 0;
		int[] res = new int[n];
		//Von hinten bestimmt
		for (int i = n; i > 0; i--) {
 
			final int target = wk[i - 1];
			int wkSum = 0;
			//Zählen Sie die Anzahl der mehreren Bälle
			for (int j = 2; (j * i - 1) < n; j++) {
				wkSum += res[j * i - 1];
			}
			//Gerade Zahl
			if (target != (wkSum % 2)) {
				res[i - 1]++;
				cnt++;
			}
		}
 
		out.println(cnt);
		if (cnt != 0) {
			StringBuilder builder = new StringBuilder();
			for (int i = 0; i < res.length; i++) {
				if (res[i] != 0) {
					builder.append(i + 1).append(" ");
				}
			}
			out.println(builder.toString());
		}
	}	

Recommended Posts

ABC - 134 - A & B & C & D & E.
ABC - 131 - A & B & C & D & E.
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 - 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.
diverta 2019 Programmierwettbewerb A & B & C & D.
AtCoder Anfängerwettbewerb 169 A, B, C mit Rubin
atcoder ABC113 C Problem
Atcoder ABC70 D Problem
ABC093 C - Gleiche Ganzzahlen
AtCoder Anfängerwettbewerb 170 A, B, C bis Rubin
atcoder ABC115 C Problem
ABC177 - E in Ruby lösen