标签:clu 示例 too 51nod print include images lin png
输入1个数N(1 <= N <= 10^18)。
输出不是2 3 5 7的倍数的数共有多少。
10
1
容斥原理
1 #include <cstdio> 2 3 #define LL long long 4 5 using namespace std; 6 7 LL n,tot; 8 9 int main() 10 { 11 scanf("%lld",&n); 12 tot=(LL)n/2+n/3+n/5+n/7; 13 tot-=(LL)(n/6+n/10+n/14+n/15+n/21+n/35); 14 tot+=(LL)n/30+n/42+n/70+n/105; 15 tot-=(LL)(n/210); 16 printf("%lld",n-tot); 17 return 0; 18 }
标签:clu 示例 too 51nod print include images lin png
原文地址:http://www.cnblogs.com/Shy-key/p/7141899.html