사칙연산

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/백준] 9723 - Right Triangle [python]

문제 링크 9723번: Right Triangle For each test case, the output contains a line in the format Case #x: M, where x is the case number (starting from 1) and M is “YES” when the given triangle is a right triangle or “NO” otherwise. Note that the quotes are not required to be outputte www.acmicpc.net 문제 풀이 테스트마다 입력값들이 직각삽각형이 가능한 지 피타고라스 정리를 통해 판단한다. 정답 코드 for i in range(1, int(input()) + 1) : triangle = ..

Algorithm/PS

[BOJ/백준] 9713 - Sum of Odd Sequence [python]

문제 링크 9713번: Sum of Odd Sequence First line of the input contains T, the number of test cases. Each test case contains a single integer N. N is between 1 and 100. www.acmicpc.net 문제 풀이 주어진 케이스의 입력값마다 1부터 입력값까지의 홀수의 합을 구해 출력해준다. 정답 코드 for _ in range(int(input())) : n = int(input()) ans = 0 for i in range(1, n + 1, 2) : ans += i print(ans)

Algorithm/PS

[BOJ/백준] 9622 - Cabin Baggage [python]

문제 링크 9622번: Cabin Baggage The first line contains an integer t (1≤ t ≤ 300) which determines the number of test cases (i.e. cabin baggage to verify). The following t lines contain the measurement of cabin baggage. Each line contains 4 values which are length, width, depth and w www.acmicpc.net 문제 풀이 문제의 조건에 맞게 입력값을 처리해주면 된다. 정답 코드 cnt = 0 for _ in range(int(input())) : a, b, c, d = map(float, i..

Algorithm/PS

[BOJ/백준] 9550 - 아이들은 사탕을 좋아해 [python]

문제 링크 9550번: 아이들은 사탕을 좋아해 각 테스트 케이스마다 생일파티에 최대 몇 명의 아이들이 참석할 수 있는지 하나의 정수로 출력한다. www.acmicpc.net 문제 풀이 주어진 입력값을 조건에 따라 처리해주는 문제이다. 파이썬에서는 쉽게 몫을 구할 수 있고 리스트 컴프리헨션을 통해 간단하게 풀어줄 수 있다. 정답 코드 for _ in range(int(input())) : N, K = map(int, input().split()) candy = [*map(int, input().split())] print(sum([i // K for i in candy]))

Algorithm/PS

[BOJ/백준] 9493 - 길면 기차, 기차는 빨라, 빠른 것은 비행기 [python]

문제 링크 9493번: 길면 기차, 기차는 빨라, 빠른 것은 비행기 한 줄에 테스트 케이스가 하나씩 주어진다. 각 테스트 케이스는 세 개의 정수 M(1 ≤ M ≤ 10,000), A 그리고 B(1 ≤ A < B ≤ 1000)로 이루어져 있다. 정수는 공백으로 구분되어 있다. 마지막 테스트 케이 www.acmicpc.net 문제 풀이 주어진 입력값을 통해 기차가 걸린 시간과 비행기가 걸린 시간의 차를 구해준 뒤, 초 단위로 변경해서 조건대로 출력해주면 된다. 단, 반올림을 해야하는 것에 주의하자. 정답 코드 import sys input = sys.stdin.readline hour_to_sec = 3600 min_to_sec = 60 while True: M, A, B = map(float, input(..

Algorithm/PS

[BOJ/백준] 9469 - 폰 노이만 [python]

문제 링크 9469번: 폰 노이만 250마일 길이의 철로 양 끝에 두 기차 A와 B가 있다. A는 시속 10마일, B는 시속 15마일로 서로를 향해 출발했다. 두 기차의 출발과 동시에 기차 A 앞에 붙어있던 파리 한 마리가 기차가 충돌할 때 까 www.acmicpc.net 문제 풀이 이 문제의 공식은 [거리 / 두 기차의 속도의 합 * 파리의 속도] 이다. 정답 코드 for i in range(1, int(input()) + 1) : N, D, A, B, F = map(float, input().split()) print(int(N), D / (A + B) * F)

Algorithm/PS

[BOJ/백준] 9443 - Arrangement of Contest [python]

문제 링크 9443번: Arrangement of Contest Little Dmitry and little Petr want to arrange a contest. Their little friends submitted several task proposals and now Dmitry and Petr want to select some of them for the contest. As they are just little boys, they cannot estimate quality of tasks, but the www.acmicpc.net 문제 풀이 이 문제는 set 자료구조를 활용해서 주어지는 입력값의 첫 번째 문자들의 종류를 구해준다. 그 후, A ~ Z 까지 순차적으로 set안에 포함되어있는..

chanwoong1
'사칙연산' 태그의 글 목록 (2 Page)