-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsum100.java
More file actions
35 lines (26 loc) Β· 871 Bytes
/
sum100.java
File metadata and controls
35 lines (26 loc) Β· 871 Bytes
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
package basic.baaarking;
import java.util.Scanner;
/*
λ°°μ΄μ μ
λ ₯ λ°μμ λ
ν΄λΉ λ°°μ΄μμ ν©μ΄ 100μ΄ λλ 2κ°μ μ«μκ° μλμ§ νμΈνλ λ¬Έμ
μ
λ ₯μ 1 <= input <= 100μ λ²μλ‘ μ΄λ£¨μ΄μ§λ©°
ν μ€μ 곡백μΌλ‘ λλμ΄ μ‘΄μ¬(ex 1 2 3 100)
κΈ°μ‘΄ λͺ¨λ λ°°μ΄μ κ°μ λΉκ΅νλ O(N^2) λ³΄λ€ μ§§μ O(N) λ§μ λ¬Έμ κ° ν΄κ²°
*/
public class sum100 {
public static void main(String[] args){
Scanner scan =new Scanner(System.in);
int[] arr = new int[101];
String input = scan.nextLine();
String[] num = input.split(" ");
int result=0;
for(String a :num){
if(arr[100-Integer.parseInt(a)]==1){
result = 1;
}
arr[Integer.parseInt(a)] =1;
}
System.out.print(result);
scan.close();
}
}