結果
| 問題 |
No.1946 ロッカーの問題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-06-07 21:23:58 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,303 ms / 3,000 ms |
| コード長 | 2,712 bytes |
| コンパイル時間 | 1,997 ms |
| コンパイル使用メモリ | 196,224 KB |
| 最終ジャッジ日時 | 2025-01-29 18:56:03 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
ソースコード
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
const int INF = 1e9;
const ll LINF = 1e18;
const double eps = 1e-10;
#define fi first
#define se second
#define eb emplace_back
#define rep(i,n) for(ll i = 0; i < (ll)(n); ++i)
#define srep(i, s, n) for (ll i = s; i < (ll)(n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fore(i,x) for(auto &i:x)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define sz(x) (ll)x.size()
#define dame { puts("-1"); return;}
#define yes { puts("Yes"); return;}
#define no { puts("No"); return;}
#define ret(x) { cout<<(x)<<'\n'; return;}
bool is_pop(ll hash, ll d){return (hash>>d)&1;}
template<typename T> using vc = vector<T>;
template<typename T> using vv = vc<vc<T>>;
template<typename T> using PQ = priority_queue<T,vc<T>,greater<T>>;
template<class... T>void in(T&... a) { (cin >> ... >> a); }
void out() { cout << '\n'; }
template<class T, class... Ts>void out(const T& a, const Ts&... b) { cout << a;(cout << ... << (cout << ' ', b));cout << '\n'; }
template< typename T >istream &operator>>(istream &is, vector< T > &v){for(T &in : v) is >> in;return is;}
template< typename T >ostream &operator<<(ostream &os, const vector< T > &v){for(int i = 0; i < (int) v.size(); i++) {os << v[i] << (i + 1 != (int) v.size() ? " " : "");}return os;}
template<class... T>constexpr auto min(T... a) { return min(initializer_list<common_type_t<T...>>{a...}); }
template<class... T>constexpr auto max(T... a) { return max(initializer_list<common_type_t<T...>>{a...}); }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void MAIN(); int main() { cin.tie(0); ios::sync_with_stdio(false); MAIN(); }
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
void MAIN()
{
ll n,m;
in(n,m);
vl a(n+1);
rep(i,m) {
ll A;
in(A);
a[A] = 1;
}
vl v(n+1);
srep(i,1,n+1) {
for (ll j = 1; j * j <= i; j++)
{
if(i % j == 0) {
if(j == i/j) v[j] ^= 1;
else {
v[j] ^= 1;
v[i/j] ^= 1;
}
}
}
}
ll ans = 0;
drep(i,n+1) {
if(a[i] == v[i]) continue;
ans++;
for (ll j = 1; j * j <= i; j++)
{
if(i % j == 0) {
if(j == i/j) v[j] ^= 1;
else {
v[j] ^= 1;
v[i/j] ^= 1;
}
}
}
}
out(ans);
}