반응형
```
백준 23530번 Not A + B JAVA 구현해보기
```
이번 글을 통해 배워갈 내용
- 백준 23530번 풀이
https://www.acmicpc.net/problem/23530
23530번: Not A + B
You are required to output an integer $c$ for each test in a separate line. If there are multiple solutions, you may output any of them.
www.acmicpc.net
백준 23530번 Not A + B은
테스트 케이스만큼 입력을 받고
1부터 50 사이의 수 중 아무 수나 두 수의 합이 아닌 수를 출력해주면 됩니다.
30분 정도 위에 링크를 방문하셔서 풀어보시고
안 풀리시는 경우에만 아래 해답을 봐주시면 감사하겠습니다.
저는 1이 아니면 1을 출력하고 1이면 2를 출력했습니다.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
public static void main(String[] args) throws IOException {
int testCase = Integer.parseInt(br.readLine());
StringBuilder sb = new StringBuilder();
for (int i=0;i<testCase;i++){
StringTokenizer st = new StringTokenizer(br.readLine(), " ");
int a = Integer.parseInt(st.nextToken());
int b = Integer.parseInt(st.nextToken());
int notSum = a+b;
if(notSum != 1){
notSum = 1;
}else {
notSum = 2;
}
sb.append(notSum).append("\n");
}
sb.setLength(sb.length()-1);
System.out.print(sb);
}
}
읽어주셔서 감사합니다
무엇인가 얻어가셨기를 바라며
오늘도 즐거운 코딩 하시길 바랍니다 ~ :)
728x90
반응형
'Java > Java 알고리즘' 카테고리의 다른 글
백준 14226번 이모티콘 JAVA 구현해보기 (0) | 2022.02.09 |
---|---|
백준 23348번 스트릿 코딩 파이터 JAVA 구현해보기 (0) | 2022.02.08 |
백준 23971번 ZOAC 4 JAVA 구현해보기 (0) | 2022.02.08 |
백준 15829번 Hashing JAVA 구현해보기 (0) | 2022.02.08 |
백준 11656번 접미사배열 JAVA 구현해보기 (0) | 2022.02.08 |