반응형
15596번
1
2
3
4
5
6
7
8
9
|
public class Test{
public long sum(int[] a) {
long sum = 0;
for(int i = 0; i < a.length; i++) {
sum += a[i];
}
return sum;
}
}
|
cs |
4673번
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
|
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
StringBuilder sb = new StringBuilder();
boolean check[] = new boolean[10001];
for(int i = 1; i < 10000; i++) {
int n = d(i);
if(n < 10001) {
check[n] = true;
}
}
for(int i = 1; i < check.length; i++) {
if(!check[i]) {
sb.append(i + "\n");
}
}
System.out.println(sb);
}
public static int d(int num) {
int sum = num;
while(num != 0) {
sum += num % 10;
num = num / 10;
}
return sum;
}
}
|
cs |
1065번
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
|
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int cnt = 0;
int N = Integer.parseInt(br.readLine());
if(N < 100) {
System.out.println(N);
}
else{
cnt = 99;
for(int i = 100; i <= N; i++) {
cnt += d(i);
}
if(N == 1000)
cnt--;
System.out.println(cnt);
}
}
public static int d(int num) {
int A = num / 100 % 10;
int B = num / 10 % 10;
int C = num % 10;
if(B * 2 == A + C) {
return 1;
}
return 0;
}
}
|
cs |
반응형
'백준' 카테고리의 다른 글
백준 8단계 (기본 수학1) (0) | 2021.04.15 |
---|---|
백준 7단계 (문자열) (0) | 2021.04.15 |
백준 5단계 (1차원 배열) (0) | 2021.04.08 |
백준 4단계 (while문) (0) | 2021.04.06 |
백준 3단계(for문) (0) | 2021.04.01 |