[ACM][2018北理校赛]签到题 【补】

Description

作为签到题当然是很水的啦。你只要输出n!可以被多少个2整除就可以了。

Input

多组数据,每组数据输入一个n(1 <= n <= 10^18)

Output

每组数据输出一行,输出n!可以被多少个2整除。

扫描二维码关注公众号,回复: 2412376 查看本文章

Sample Input 1 

2
4

Sample Output 1

1
3

题意:给你个数 求阶乘能被多少个2整除

思路:模拟就好 记住数很大 用long long

AC代码:

#include <bits/stdc++.h>

using namespace std;

int main() {
	long long n;
	while (cin >> n) {
		long long cnt = 0;
		while (n) {
			n /= 2;
			cnt += n;
		}
		cout << cnt << endl;
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_40731186/article/details/80051930
今日推荐