結果

問題 No.1946 ロッカーの問題
ユーザー harurunharurun
提出日時 2022-05-20 23:10:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 701 ms / 3,000 ms
コード長 1,395 bytes
コンパイル時間 3,373 ms
コンパイル使用メモリ 186,032 KB
実行使用メモリ 4,892 KB
最終ジャッジ日時 2023-10-20 14:03:35
合計ジャッジ時間 6,813 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 3 ms
4,892 KB
testcase_03 AC 569 ms
4,892 KB
testcase_04 AC 3 ms
4,892 KB
testcase_05 AC 11 ms
4,364 KB
testcase_06 AC 14 ms
4,628 KB
testcase_07 AC 10 ms
4,364 KB
testcase_08 AC 121 ms
4,348 KB
testcase_09 AC 486 ms
4,628 KB
testcase_10 AC 389 ms
4,628 KB
testcase_11 AC 7 ms
4,348 KB
testcase_12 AC 66 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 256 ms
4,348 KB
testcase_18 AC 701 ms
4,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <string>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <stack>
#include <random>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <assert.h>
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
using namespace std;
using ll=long long;
#define read(x) cin>>(x);
#define readll(x) ll (x);cin>>(x);
#define readS(x) string (x);cin>>(x);
#define readvll(x,N) vector<ll> (x)((N));for(int i=0;i<(N);i++){cin>>(x)[i];}
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define rep2d(i,j,H,W) for(ll (i)=0;(i)<(H);(i)++)for(ll (j)=0;(j)<(W);j++)
#define is_in(x,y) (0<=(x) && (x)<H && 0<=(y) && (y)<W)
#define yn {cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

int main(){
  ll N,M;
  cin>>N>>M;
  vector<ll> A(N);
  rep(i,M){
    ll a;
    cin>>a;
    A[a-1]++;
  }
  ll ans=0;
  for(ll i=N-1;i>=0;i--){
    if(A[i]==1){
      //cerr<<"%:"<<i+1<<endl;
      for(ll j=1;j*j<=i+1;j++){
        if((i+1)%j==0){
          //cerr<<j<<endl;
          A[j-1]=1-A[j-1];
          if((i+1)/j!=j){
            A[(i+1)/j-1]=1-A[(i+1)/j-1];
          }
        }
      }
    }else{
      //cerr<<"!:"<<i+1<<endl;
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}
0