SWEA_8658) Summation
SWEA
# D3
8658) Summation (19.10.15)
문제 링크 (SW Expert Academy)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
import java.io.*;
import java.util.*;
public class Solution {
public static int max = 0;
public static int min = 60;
public static void cal(int[] ans, int c, int k) {
int sum = 0;
while(k>0) {
sum = sum+k%10;
k = k/10;
}
ans[c] = sum;
if(max<sum) max = sum;
if(min>sum) min = sum;
}
public static void main(String args[]) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
StringTokenizer tk;
int test = Integer.parseInt(br.readLine());
for(int i=1;i<=test;i++) {
int[] ans = new int[10];
tk = new StringTokenizer(br.readLine());
for(int c=0;c<10;c++) {
int k = Integer.parseInt(tk.nextToken());
cal(ans, c, k);
}
bw.write("#" + i + " " + max + " " + min + "\n");
max = 0;
min = 60;
}
bw.flush();
bw.close();
}
}
| cs |
댓글
댓글 쓰기