题解 | #Problem C#
Problem C
https://www.nowcoder.com/practice/2a05dcaa4cde4db989443f206ee3e5c5
while True: try: t = int(input()) # 获取测试用例的数量 for _ in range(t): s = input().strip() # 获取输入字符串 n = ''.join(i for i in s if i.isdigit()) # 提取数字部分 if not n: print(0) continue n = int(n) if n == 1: print(0) continue # 找到最小的质因数 for i in range(2, int(n ** 0.5) + 1): if n % i == 0: while n % i == 0: n //= i if n == 1: print(i) break else: if n > 1: print(n) except: break