#45001: python 54ms


x__1 (~7年級~破防之頌_600題了)

學校 : 臺北市立麗山國中
編號 : 294220
來源 : [223.136.77.14]
最後登入時間 :
2025-01-21 13:45:02
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