#include <cstdlib>
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
long long int a;
long long int c ,k ;
while( cin >> a )
{
k = 0;
if(a <=4)
{
cout << "0"<<endl;
}
else
{
for(int i = 5 ; i<=a;i+=5)
{
c= i;
while(c%5 == 0 and c !=0)
{
k+=1;
c= c/5;
}
}
cout << k <<endl ;
}
}
system("PAUSE");
return 0;
}
我輸入1000000 它跑的出來說 可是它仍然說我TLE...可以幫幫我嗎?
#include
#include
#include
using namespace std;
int main()
{
long long int a;
long long int c ,k ;
while( cin >> a )
{
k = 0;
if(a <=4)
{
cout << "0"< }
else
{
for(int i = 5 ; i<=a;i+=5)
{
c= i;
while(c%5 == 0 and c !=0)
{
k+=1;
c= c/5;
}
}
cout << k < }
}
system("PAUSE");
return 0;
}
我輸入1000000 它跑的出來說 可是它仍然說我TLE...可以幫幫我嗎?
else 裡面用一個 while 就夠了