ABC --016 --A & B & C

AtCoder ABC 016 A&B&C AtCoder - 016

A --December 6th

	private void solveA() {
		int m = nextInt();
		int d = nextInt();
		out.print(m % d == 0 ? "YES" : "NO");
	}

B - A±B Problem

	private void solveB() {
		int a = nextInt();
		int b = nextInt();
		int c = nextInt();

		boolean p = a + b == c;
		boolean m = a - b == c;

		if (p && m) {
			out.println("?");
		} else if (!p && !m) {
			out.println("!");
		} else if (p && !m) {
			out.println("+");
		} else if (!p && m) {
			out.println("-");
		}

	}

C-friend of a friend

--Find the distance between the vertices of the undirected graph --With friends at the top --The distance to friends is 1 (the distance between friends is the same) --Friends of friends have a distance of 2 between vertices ――Friend of a friend's friend has a distance of 3 between vertices

It's time to learn how to solve it other than the Worshall Floyd method. .. ..

	private void solveC() {
		int n = nextInt();
		int m = nextInt();

		int[] a = new int[m];
		int[] b = new int[m];
		int[][] graph = new int[n][n];
		for (int i = 0; i < n; i++) {
			//Fill with MAX
			Arrays.fill(graph[i], Integer.MAX_VALUE / 2);
			//The cost of moving to yourself is 0
			graph[i][i] = 0;
		}
		for (int i = 0; i < m; i++) {
			a[i] = nextInt() - 1;
			b[i] = nextInt() - 1;
			//Creating an adjacency matrix
			graph[a[i]][b[i]] = 1;
			graph[b[i]][a[i]] = 1;
		}

		//Floyd-Warshall Floyd method
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				for (int k = 0; k < n; k++) {
					graph[j][k] = Integer.min(graph[j][k], graph[j][i] + graph[i][k]);
				}
			}
		}

		/*
		 *Travel cost from yourself
		 * 1=friend
		 * 2=A friend of a friend
		 * 3=Friend of a friend friend of a friend
		 * 4=Friend of a friend Friend of a friend ...
		 *Continued below
		 */
		for (int i = 0; i < graph.length; i++) {
			int res = 0;
			for (int j = 0; j < graph.length; j++) {
				res += graph[i][j] == 2 ? 1 : 0;
			}
			out.println(res);
		}
	}

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 --022 --A & B & C
ABC --019 --A & B & C
ABC --020 --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
atcoder ABC115 C problem
AtCoder Beginner Contest 170 A, B, C up to ruby
Make a SOAP call in C #
Call a C function from Swift
NLP4J [006-034] 100 language processing knocks with NLP4J # 34 "A B"