본문 바로가기

Python/code problem

[sw expert academy] 10570. 제곱 팰린드롬 수

https://swexpertacademy.com/main/main.do

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com

 

T= int(input())
for t in range(1,T+1):
  A,B = map(int,input().split())
  a,b = (A**(1/2),B**(1/2))
  if a != int(a):
    a = int(a)+1
  else:
    a = int(a)
  b = int(b)
  result = 0
  for i in range(a,b+1):
    st = str(i)
    if st[:len(st)//2] == st[len(st)-1 : len(st)-1-(len(st)//2) : -1]:
        k = str(i**2)
        if k[:len(k)//2] == k[len(k)-1 : len(k)-1-(len(k)//2):-1]:
            result +=1
  
  print('#{} {}'.format(t,result))