第五题 找完全平方数 从子节点往前找即可ac。 import math def is_pownum(num): if math.sqrt(num)%1==0: return True else: return False n = int(input()) a = [int(x) for x in input().split()] father = [int(x) for x in input().split()] count=0 for i in range(n-1,-1,-1): j = i while j>0: j = father[j - 1] - 1 if is_pownum(a[i]*a[j]): count+=1 print(count)

相关推荐

不愿透露姓名的神秘牛友
10-04 05:12
kalistar:简历留六个字,北京大学(本科),黑体加粗,看看哪个hr不长眼敢碰瓷我们北大✌
点赞 评论 收藏
分享
敢逐云霄志:你打招呼语怎么能这么长,hr都没看下去的欲望,简明扼要说重点,就读于某某学校某某专业,26届应届毕业生,学信网可查,先后在某某公司实习过(如有),然后做过什么项目,想找一份什么样的工作,可实习几个月以上,期待您的回复。
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务