标签:
Time Limit: 12000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 6001 Accepted Submission(s): 1722
题解:wa
代码:
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<vector> using namespace std; vector<int>p; typedef long long LL; void rc(int x){ LL sum=0; for(int i=1;i<(1<<p.size());i++){ LL num=0,cur=1; for(int j=0;j<p.size();j++){ if(i&(1<<j)){ num++; cur*=p[j]; } } if(num&1)sum+=x/cur-1; else sum-=x/cur-1; } printf("%lld\n",sum); } int main(){ int N,M,x; while(~scanf("%d%d",&N,&M)){ p.clear(); for(int i=0;i<M;i++){ scanf("%d",&x); if(x==0)continue; p.push_back(x); } rc(N); } return 0; }
How many integers can you find(容斥)
标签:
原文地址:http://www.cnblogs.com/handsomecui/p/4989977.html