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 - 041- A&B&C

Posted at

AtCoder ABC 041 A&B&C

AtCoder - 041

A問題

  • 文字列切り出し
	private void solveA() {
		String wk = next();
		int numI = nextInt();

		out.println(wk.substring(numI - 1, numI));
	}

B問題

  • 剰余の性質
    • $(A × B) ; mod ; M = ((A ; mod ; M) × (B ; mod ; M)) ; mod ; M$
	private void solveB() {
		long numA = nextLong();
		long numB = nextLong();
		long numC = nextLong();

		long CONST_MOD = (long) (Math.pow(10, 9) + 7);

		long res = numA * numB % CONST_MOD * numC % CONST_MOD;

		out.println(res);
	}

C問題

  • 二次元配列をソートするだけなのでjavaだとすごく簡単
  • 次はGOでこの実装を試す
	private void solveC() {
		int numN = nextInt();
		int[][] wk = IntStream.range(0, numN).collect(() -> new int[numN][2],
				(t, i) -> {
					t[i][0] = i + 1;
					t[i][1] = nextInt();
				}, (t, u) -> {
					Stream.concat(Arrays.stream(t), Arrays.stream(u));
				});

		Arrays.sort(wk, (x, y) -> {
			if (x[1] < y[1]) {
				return 1;
			} else if (x[1] > y[1]) {
				return -1;
			} else {
				if (x[0] < y[0]) {
					return -1;
				} else if (x[0] > y[0]) {
					return 1;
				} else {
					return 0;
				}
			}
		});

		for (int j = 0; j < wk.length; j++) {
			out.println(wk[j][0]);
		}
	}
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?