https://www.acmicpc.net/problem/1977
1977번: 완전제곱수
M과 N이 주어질 때 M이상 N이하의 자연수 중 완전제곱수인 것을 모두 골라 그 합을 구하고 그 중 최솟값을 찾는 프로그램을 작성하시오. 예를 들어 M=60, N=100인 경우 60이상 100이하의 자연수 중 완
www.acmicpc.net
https://github.com/stellaluminary/Baekjoon
GitHub - stellaluminary/Baekjoon
Contribute to stellaluminary/Baekjoon development by creating an account on GitHub.
github.com
n = int(input())
m = int(input())
t = [i**2 for i in range(1,101)]
s = []
for i in t:
if n <= i <= m:
s.append(i)
if len(s):
print(sum(s))
print(min(s))
else:
print(-1)
n = int(input())
m = int(input())
t = [i**2 for i in range(101) if n <= i**2 <= m]
print(f'{sum(t)}\n{t[0]}'if t else -1)