标签:des style java color os strong io for
12 2 2 3
7
#include <iostream> #include <cstdio> #include <cstring> #include <vector> #include <string> #include <algorithm> #include <queue> using namespace std; typedef long long ll; int n,m; vector<int> num; int gcd(int a,int b){ if(b==0) return a; return gcd(b,a%b); } int Lcm(int a,int b){ return a/gcd(a,b)*b; } void solve(){ vector<int> dig; int ans = 0; for(int i = 1; i < (1<<m); i++){ dig.clear(); for(int j = 0; j < m; j++){ if(i & (1<<j)) dig.push_back(j); } int t = 1; for(int j = 0; j < dig.size(); j++){ t = Lcm(t,num[dig[j]]); } if(dig.size()%2==0) ans -= n/t; else ans += n/t; } cout<<ans<<endl; } int main(){ while(~scanf("%d%d",&n,&m)){ n--; num.clear(); int tn; for(int i = 0; i < m; i++){ scanf("%d",&tn); if(tn!=0) num.push_back(tn); } m = num.size(); solve(); } return 0; }
HDU1796-How many integers can you find,布布扣,bubuko.com
HDU1796-How many integers can you find
标签:des style java color os strong io for
原文地址:http://blog.csdn.net/mowayao/article/details/38239207