結果

問題 No.1946 ロッカーの問題
ユーザー umezoumezo
提出日時 2022-05-20 22:36:46
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 236 ms / 3,000 ms
コード長 674 bytes
コンパイル時間 2,050 ms
コンパイル使用メモリ 204,860 KB
実行使用メモリ 27,056 KB
最終ジャッジ日時 2023-10-20 13:21:47
合計ジャッジ時間 7,560 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 177 ms
25,004 KB
testcase_01 AC 182 ms
25,004 KB
testcase_02 AC 208 ms
26,264 KB
testcase_03 AC 230 ms
27,056 KB
testcase_04 AC 207 ms
26,264 KB
testcase_05 AC 210 ms
25,736 KB
testcase_06 AC 216 ms
26,000 KB
testcase_07 AC 236 ms
25,736 KB
testcase_08 AC 198 ms
25,472 KB
testcase_09 AC 232 ms
26,792 KB
testcase_10 AC 206 ms
26,528 KB
testcase_11 AC 190 ms
25,084 KB
testcase_12 AC 228 ms
25,472 KB
testcase_13 AC 218 ms
25,004 KB
testcase_14 AC 203 ms
25,004 KB
testcase_15 AC 204 ms
25,132 KB
testcase_16 AC 202 ms
25,004 KB
testcase_17 AC 218 ms
25,736 KB
testcase_18 AC 220 ms
26,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;

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

vector<int> G[200200];

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  for(int i=1;i<=200000;i++){
    for(int j=i;j<=200000;j+=i) G[j].push_back(i);
  }
  
  int n,m;
  cin>>n>>m;
  vector<int> A(m);
  rep(i,m) cin>>A[i];
  
  vector<int> B(n+1),C(n+1);
  rep(i,m) C[A[i]]=1;
  for(int i=1;i<=n;i++) B[i]=n/i;

  int cnt=0;
  for(int i=n;i>=1;i--){
    if(B[i]%2!=C[i]){
      cnt++;
      for(auto t:G[i]){
        if(t==i) break;
        B[t]--;
      }
    }
  }
  cout<<cnt<<endl;

  return 0;
}
0