#4683: TLE


laqq666 (顝猈)

學校 : 國立彰化高級中學
編號 : 13443
來源 : [163.23.148.201]
最後登入時間 :
2011-04-14 14:52:06
d121. 00583 - Prime Factors -- UVa583 | From: [163.23.148.202] | 發表日期 : 2010-12-23 14:58

#include <iostream>
using namespace std;
int main()
 {
  long long x;
  while(cin>>x)
  {
   if(x==0) break;
   cout<<x<<" = ";
   if(x<0)
   {
    cout<<" -1 x";
    x=-1*x;
   }
   for(int i=2;i*i<=x+1;i++)
   {
    while(x%i==0&&x!=i)
    {
     cout<<" "<<i<<" x";
     x=x/i;
    }
   }
   if(x!=1) cout<<" "<<x<<'\n';
  }
 return 0; 
 }

一直TLE 不知怎樣可以更快??

 
#4740: Re:TLE


linishan (L)

學校 : 國立交通大學
編號 : 1090
來源 : [104.132.150.102]
最後登入時間 :
2019-05-10 19:57:54
d121. 00583 - Prime Factors -- UVa583 | From: [125.226.10.251] | 發表日期 : 2011-01-10 20:01

prime table

http://www.csie.ntnu.edu.tw/~u91029/Prime.html

 
ZeroJudge Forum