Poj Solution 1401

http://poj.org/problem?id=1401

#include <iostream>
 
using namespace std;
 
int calc(int z)
{
    int i, count = 0;
    for (i = 5; i <= z; i *= 5)
    {
        count += z / i;
    }
    return count;
}
 
int main()
{
    int n, z;
    cin >> n;
    while (n--)
    {
        cin >> z;
        cout << calc(z) << endl;
    }
    //system("pause");
    return 0;
}
											
This entry was posted in poj. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *