Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- int main()
- {
- ll n,k;
- cin>>n>>k;
- ll a[k+1];
- for (ll i=1; i<=k; i++) cin>>a[i];
- vector<pair<ll,ll>> v,res;
- v.push_back({a[1],-1});
- for (ll i=2; i<=k; i++){
- for (auto u:v){
- res.push_back({(u.first)*a[i],(u.second)*(-1)});
- }
- v.push_back({a[i],-1});
- for (auto u:res){
- v.push_back({u.first,u.second});
- }
- res.clear();
- }
- ll ans=0;
- for (auto u:v){
- ans=ans-(n/u.first)*(u.second);
- }
- cout<<ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement