結果

問題 No.1946 ロッカーの問題
ユーザー cho435
提出日時 2022-05-25 09:15:09
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 638 ms / 3,000 ms
コード長 550 bytes
コンパイル時間 1,777 ms
コンパイル使用メモリ 173,116 KB
実行使用メモリ 13,428 KB
最終ジャッジ日時 2024-09-20 14:41:22
合計ジャッジ時間 5,143 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i=0;i<(int)(n);i++)

int main(){
  int n,m;
  cin>>n>>m;
  priority_queue<int> pq;
  rep(i,m){
    int a;
    cin>>a;
    pq.push(a);
  }
  int cn=0;
  while(!pq.empty()){
    int x=pq.top();
    pq.pop();
    if(!pq.empty()&&(x==pq.top())) {
      pq.pop();
      continue;
    }
    cn++;
    for(int i=2;i*i<=x;i++){
      if(x%i==0){
        pq.push(i);
        if(i!=x/i) pq.push(x/i);
      }
    }
    if(x!=1) pq.push(1);
  }
  cout<<n-cn<<endl;
}
0