Programming/Python & Data Structures
[Baekjoon/Python3] 1977번 완전제곱수
HooNeee
2020. 12. 3. 01:09
[Baekjoon/Python3] 1977번 완전제곱수
1977번: 완전제곱수
M과 N이 주어질 때 M이상 N이하의 자연수 중 완전제곱수인 것을 모두 골라 그 합을 구하고 그 중 최솟값을 찾는 프로그램을 작성하시오. 예를 들어 M=60, N=100인 경우 60이상 100이하의 자연수 중 완
www.acmicpc.net
import math as h
m = int(input())
n = int(input())
nums = []
for i in range(h.ceil(h.sqrt(m)), h.floor(h.sqrt(n) + 1)):
nums.append(pow(i, 2))
if len(nums) == 0:
print(-1)
else:
print(sum(nums), nums[0], sep='\n')