AtCoder ABC 041 A&B&C
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]);
}
}