[51nod]1284 2 3 5 7的倍数(容斥原理)

题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1284

 1 #include <iostream>
 2 
 3 using namespace std;
 4 
 5 long long n;
 6 int main()
 7 {
 8     cin>>n;
 9     cout<<(n-n/2-n/3-n/5-n/7+n/6+n/10+n/14+n/15+n/21+n/35-n/30-n/70-n/105-n/42+n/210);
10     return 0;
11 }

 

posted @ 2018-04-03 19:56  Somnus、M  阅读(93)  评论(0编辑  收藏  举报