結果

問題 No.1946 ロッカーの問題
ユーザー くまくま
提出日時 2022-06-07 21:23:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,304 ms / 3,000 ms
コード長 2,712 bytes
コンパイル時間 2,112 ms
コンパイル使用メモリ 204,148 KB
実行使用メモリ 6,380 KB
最終ジャッジ日時 2023-10-21 03:53:11
合計ジャッジ時間 11,639 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1,304 ms
6,380 KB
testcase_03 AC 825 ms
6,380 KB
testcase_04 AC 1,304 ms
6,380 KB
testcase_05 AC 817 ms
5,588 KB
testcase_06 AC 967 ms
5,852 KB
testcase_07 AC 667 ms
5,324 KB
testcase_08 AC 168 ms
4,348 KB
testcase_09 AC 705 ms
6,116 KB
testcase_10 AC 562 ms
5,588 KB
testcase_11 AC 9 ms
4,348 KB
testcase_12 AC 316 ms
4,532 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 45 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 246 ms
4,796 KB
testcase_18 AC 685 ms
6,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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);
}
0