SWEA
[SWEA] 서랍의 비밀번호
itsnot4me
2024. 9. 16. 22:04
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
import java.util.Scanner;
import java.io.FileInputStream;
class Solution
{
public static void main(String args[]) throws Exception
{
Scanner sc = new Scanner(System.in);
int P=sc.nextInt();
int K=sc.nextInt();
int score=0;
for(int test_case = 0; P>K; test_case++)
{
score = score +1;
K = K + 1;
if(P==K)
break;
}
System.out.println(score+1);
}
}
굳이 문제 풀 때 할 필요는 있나? 생각하지만 P가 K보다 같거나 작은 경우라던가 하면 오류 메시지 출력을 한다거나 해야겠습니다