Algorithm/PS

Algorithm/PS

[BOJ/백준] 9907 - ID [python]

문제 링크 9907번: ID The National Identity Card number of the city state of Eropagnis, NICE, consists of seven digits and a letter appended behind. This letter is calculated from the digits using the Modulo Eleven method. The steps involved in the computation are as follows: www.acmicpc.net 문제 풀이 문제에 주어진대로 입력값의 각 자릿수마다 숫자를 곱해준 뒤, 그 합을 11로 나눈 나머지를 "JABCDEFHIZ"의 인덱스로 매핑한다. 정답 코드 id_map = "JABCDEFGHIZ" ..

Algorithm/PS

[BOJ/백준] 9848 - Gift [python]

문제 링크 9848번: Gift The first line contains 2 integers n and k, where n (3 ≤ n ≤ 100) is the number of days, and k (0 < k ≤ 100,000) the desired improvement (in milliseconds). Whenever Jacqueline’s timing reduces by at least k milliseconds over the previous day’s ti www.acmicpc.net 문제 풀이 첫 줄에 주어진 K를 가지고 각각의 입력값을 전 입력값과 비교했을 때 차이가 K이상일 경우의 수를 구해 출력한다. 정답 코드 n, K = map(int, input().split()) ans = 0 ..

Algorithm/PS

[BOJ/백준] 9838 - XMAX [python]

문제 링크 9838번: XMAS Your program must write a mapping from the guests to the recipients of their gifts to the standard output. The first line contains an integer indicating the recipient of the gift brought by guest 1. Similarly, the second line contains an integer indicating www.acmicpc.net 문제 풀이 입력된 값을 인덱스로, 들어온 순서를 값으로 정해준 뒤, 순서대로 출력해준다. 정답 코드 n = int(input()) lst = [0] * (n + 1) for i in range..

Algorithm/PS

[BOJ/백준] 9783 - Easy Encryption [python]

문제 링크 9783번: Easy Encryption In order to send a secret message to your friend, you invent an original method to encrypt the message. The encryption rule is quite simple. A letter is replaced with 2-digit number. Each letter has its corresponding number as the following: a = 01, b = 02 www.acmicpc.net 문제 풀이 입력값을 문제의 규칙에 따라 변환해 출력해주는 문제이다. 알파벳은 소문자 a부터 z까지 01 ~ 26으로 변환해 출력해준다. 대문자는 A ~ Z 까지 27 ~ 5..

Algorithm/PS

[BOJ/백준] 9776 - Max Volume [python]

문제 링크 9776번: Max Volume The first line of the input contains a positive integer n (1 ≤ n ≤ 100) which is the number of figures. The n following lines contain the description of each figure. In case of a cone, the line begins with letter C and followed by 2 values: r and h res www.acmicpc.net 문제 풀이 입력값은 구, 원기둥, 원뿔로 들어오게 되는데, 각각의 부피를 구해준 뒤, 가장 부피가 큰 값을 출력해준다. 정답 코드 pi = 3.14159 ans = [] for _ in r..

Algorithm/PS

[BOJ/백준] 9773 - ID Key [python]

문제 링크 9773번: ID Key บรรทัดแรกคือค่า N (1 ≤ N ≤ 100) ระบุจํานวนคน และ N บรรทัดต่อมา แต่ละบรรทัดคือเลขประจําตัวประชาชน 13 ห www.acmicpc.net 문제 풀이 이 문제는 13자리의 수가 입력되는데, 규칙 두 가지를 통해 나온 값을 더해준 뒤, 4자리로 만들어 출력해주면 된다. 각 자릿수를 모두 더해준 값 열번째 자리부터 열 세번째 자리까지 세자릿 수에 10을 곱해준 값 두 값의 합을 구해준 뒤, 값을 1000의 자리까지만 출력해준다. 만약, 값이 4자리가 되지 않을 경우, 값에 1000을 더해 출력해준다. 정답 코드 for i in range(int(input())) : id = input() ans = s..

Algorithm/PS

[BOJ/백준] 9771 - Word Searching [python]

문제 링크 9771번: Word Searching The first line contains a single word to search. A word contains at most 20 characters. The next line and the rest is a text to search for that word. The text can contain up to 100 lines including blank lines. No line exceeds 250 characters. A word cannot www.acmicpc.net 문제 풀이 EOF가 입력될 때 까지 입력값을 받으며, 입력값 중 특정한 문자가 발견된다면 그 문자가 발견된 횟수를 출력해준다. 정답 코드 s = input() cnt = 0 t..

Algorithm/PS

[BOJ/백준] 9724 - Perfect Cube [python]

문제 링크 9724번: Perfect Cube A perfect cube is an integer whose cube root is also an integer. For example 1, 8, 27, 64, 125, etc. are examples of perfect cubes but 9, 25 and 113 are not. Given two positive integers A and B, your task is to calculate the number of perfect cubes in the www.acmicpc.net 문제 풀이 두 입력값 A와 B 사이의 완전 세제곱수의 갯수를 출력해준다. 정답 코드 for i in range(1, int(input()) + 1) : A, B = map(int,..

chanwoong1
'Algorithm/PS' 카테고리의 글 목록 (2 Page)