[SWEA] 2805 농작물 수확하기

Time Lapse :15min 2sec

2805.java

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import java.io.*;

public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int tc = 1, T, N, ans, i;
String str;
T = Integer.parseInt(br.readLine());
while(T-- != 0) {
N = Integer.parseInt(br.readLine());
i = ans = 0;
do{
str = br.readLine();
for(int j = Math.abs(N / 2 - i);
i < N / 2 ? j <= N / 2 + i : j < N + N / 2 - i; ++j)
ans += str.charAt(j) & 0b1111;
}while(++i < N);
bw.write("#" + tc++ + " " + ans + "\n");
}
bw.flush();
}
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2020/08/04/PS/SWEA/2805/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.