5
true
2^2+1^2=5
25
4^2+3^2=25
24
false
1 2 3 4 5 6 7 8 9 10 11 class Solution: def square(self , c: int) -> bool: # write code here if c==1: return False for a in range(1,int(c**0.5)+1): b = c - a**2 # 检查b是否为平方数 if b**0.5 == int(b**0.5): return True return False
这道题你会答吗?花几分钟告诉大家答案吧!
扫描二维码,关注牛客网
下载牛客APP,随时随地刷题