Submission #49324

#TimeUsernameProblemLanguageResultExecution timeMemory
49324amiSažetak (COCI17_sazetak)C++14
64 / 160
1089 ms620 KiB
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using i64 = long long;

int n,m;
int a[11];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout<<fixed<<setprecision(10);

  cin>>n>>m;
  rep(i,0,m) cin>>a[i];
  a[m++]=n;

  int res=0;
  rep(i,1,n+1) {
    bool z=false;
    bool o=false;
    rep(j,0,m) {
      if (i%a[j]==0) z=true;
      if (i%a[j]==1) o=true;
    }
    if (z && o) ++res;
  }
  cout<<res<<"\n";
}
#Verdict Execution timeMemoryGrader output
Fetching results...