Created
January 12, 2021 08:52
-
-
Save utahta/7e57a59e5906a5404e8d2dadf1b5d728 to your computer and use it in GitHub Desktop.
階乗の桁数と末尾0の個数
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cmath> | |
using namespace std; | |
typedef long long ll; | |
int main() { | |
ll n; | |
cin >> n; | |
ll tmp = n; | |
ll zero = 0; | |
while (tmp >= 5) { | |
zero += tmp / 5; | |
tmp /= 5; | |
} | |
double keta = n * (log10((double)n)-0.43429448190325) + 0.5*log10(M_PI*2.0*n); | |
cout << int(keta)+1 << " " << zero << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment