結果

問題 No.1946 ロッカーの問題
ユーザー Nzt3Nzt3
提出日時 2022-05-21 01:47:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 244 ms / 3,000 ms
コード長 480 bytes
コンパイル時間 1,588 ms
コンパイル使用メモリ 169,292 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 15:27:05
合計ジャッジ時間 3,429 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 202 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 6 ms
4,348 KB
testcase_06 AC 5 ms
4,348 KB
testcase_07 AC 5 ms
4,348 KB
testcase_08 AC 44 ms
4,348 KB
testcase_09 AC 167 ms
4,348 KB
testcase_10 AC 130 ms
4,348 KB
testcase_11 AC 4 ms
4,348 KB
testcase_12 AC 24 ms
4,348 KB
testcase_13 AC 1 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 88 ms
4,348 KB
testcase_18 AC 244 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N,M;
  cin>>N>>M;
  vector<bool>op(N);
  for(int i=0,t;i<M;i++){
    cin>>t;
    op[t-1]=true;
  }
  int ans=0;
  for(int i=N;i>0;--i){
    if(!op[i-1]){
      ans+=1;
      continue;
    }
    for(int j=1;j*j<=i;j++){
      if(i%j==0){
        op[j-1]=1-op[j-1];
        if(i/j!=j){
          op[i/j-1]=1-op[i/j-1];
        }
      }
    }
  }
  cout<<ans<<'\n';
}
0