Advertisement
a53

parale

a53
Jan 15th, 2022
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include <fstream>
  2. #define N 200003
  3. using namespace std;
  4. ifstream f("parale.in");
  5. ofstream g("parale.out");
  6. int n,m,i,j,x,dn;
  7. int v[N];
  8. long long sol;
  9.  
  10. int main()
  11. {
  12. f >> n >> m;
  13. dn = 2*n;
  14. for(i = 1; i <= m; i++)
  15. {
  16. f >> x;
  17. if(v[x]==0)
  18. {
  19. j = x;
  20. while(j <= dn)
  21. {
  22. v[j] = 1;
  23. j = j+x;
  24. }
  25. }
  26. }
  27. sol = 1LL*n*n;
  28. for(i = 2; i <= n+1; i++)
  29. if(v[i]) sol -= i-1;
  30. for(i = n+2; i <= dn; i++)
  31. if(v[i]) sol -= dn-i+1;
  32. g << sol;
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement