[백준/파이썬] 15372번 풀이
업데이트:
문제 정보
- 문제 출처: 백준 온라인 저지
- 문제 링크: 15372번 문제
- 문제풀이 코드 GitHub 링크
- 제출 언어: Python 3
풀이
문제
Given a positive integer N, what is the minimum positive integer K such that K is a multiple of the square of N?
Note that a is a multiple of b if a = b · k for some integer k.
입력 요약
The first line of input will contain a single integer T, the number of test cases.
Each test case consists of a single line, containing the integer N.
Constraints
-
1 ≤ T ≤ 200000
-
1 ≤ N ≤ 200000
출력 요약
For each test case, output a single line containing the integer K, the answer for that test case.
코드
import sys;read=sys.stdin.readline
exec('print(int(read())**2);'*int(read()))
설명
핵심은 구현 관점에서 Given a positive integer N, what is the minimum positive integer K such that K is a multiple of the square of N? …를 만족하도록 로직을 구성하는 것입니다.
코드는 입력을 파싱한 뒤 조건 분기와 계산을 순서대로 수행하고, 문제에서 요구한 형식으로 결과를 출력합니다.
경계값과 예외 케이스도 함께 고려해 오답이 나기 쉬운 상황을 방지합니다.
댓글남기기