# 数学高手也会爱上毒瘤数学题2## 题目背景MRC是一个数学高手。于是冷老师就让MRC来出几套题。## 题目描述MRC经过思考想出了一道绝世毒瘤题:求1!! 2!! 3!! ···n!!WXY:好好好你这么出题是吧好好好。作为凉心出题人WXY把题目简化了只需要输出上面式子的答案的后缀 0 的个数即可。双阶乘:2k+1!! = 2k+1 2k-1 2k-3 ··· 12k!! =2k
#include <iostream>
using namespace std;
int countZeroes(int n) {
int count = 0;
while (n % 5 == 0) {
count++;
n /= 5;
}
return count;
}
int main() {
int n;
cin >> n;
int count = 0;
for (int i = 1; i <= n; i++) {
if (i % 2 == 0) {
count += countZeroes(i);
}
}
cout << count << endl;
return 0;
}
原文地址: https://www.cveoy.top/t/topic/iOSN 著作权归作者所有。请勿转载和采集!