SWEA 2043 서랍의 비밀번호

1 개요[ | ]

SWEA 2043 서랍의 비밀번호
해 = P - K + 1
  • P보다 K가 작을 경우에는, 위의 식으로 대응이 되지 않겠으나...
  • 테스트케이스에는 'P > K'인 경우만 있어서 위의 식만으로 통과된다.

2 C++[ | ]

#include <iostream>
using namespace std;
int main() {
    int P, K;
    cin >> P >> K;
    cout << P - K + 1;
}

3 Java[ | ]

import java.util.Scanner;
class Solution {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int P = sc.nextInt();
        int K = sc.nextInt();
        System.out.print(P-K+1);
    }
}

4 Python[ | ]

#kcy_code1
a, b = map(int, input().split())
cnt = 1
while(1):
    if a == b:
        print(cnt)
        break
    b = b + 1
    cnt = cnt + 1
#kcy_code2
p, k = map(int, input().split())
print(p - k +1)

5 같이 보기[ | ]

6 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}