大水题(容斥原理)
大水题
https://ac.nowcoder.com/acm/problem/15079
比较简单的容斥原理的题目
下面贴两张概念性的图片 很容易理解
话不多说就贴代码啦:
#include<iostream>
#include<algorithm>
#include<set>
#include<string>
#include<cstring>
#include<queue>
using namespace std;
#define close_stdin ios::sync_with_stdio(false)
#define P pair<int,int>
typedef long long ll;
const int maxn = 0;
int main()
{
close_stdin;
long long p;
while (cin >> p) {
ll ans = p;
ans -= (p / 2 + p / 5 + p / 11 + p / 13);
ans += (p / 10 + p / 22 + p / 26 + p / 55 + p / 65 + p / 143);
ans -= (p / 110 + p / 130 + p / 715 + p / 286);
ans += (p / 1430);
cout << ans << "\n";
}
}谢谢浏览哈!
查看30道真题和解析