#45001: python 54ms


x__1 (麗山の間諜)

學校 : 臺北市私立延平高級中學
編號 : 294220
來源 : [118.160.61.232]
最後登入時間 :
2025-04-06 18:06:43
d120. 10699 - Count the factors -- UVa10699 | From: [220.129.207.50] | 發表日期 : 2025-01-01 17:08

判斷到根號n就好了

from sys import stdin
for s in stdin:
 n=int(s)
 if not n:
  break
 print(f'{n} : ',end='')
 ans=0
 for i in range(2,int(n**0.5)+1):
  if not n%i:
   ans+=1
  while not n%i:
   n//=i
  if n==1:
   break
 if n!=1:
  ans+=1
 print(ans)
 
ZeroJudge Forum