結果

問題 No.1946 ロッカーの問題
ユーザー cho435cho435
提出日時 2022-05-25 09:15:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 615 ms / 3,000 ms
コード長 550 bytes
コンパイル時間 2,870 ms
コンパイル使用メモリ 172,280 KB
実行使用メモリ 12,064 KB
最終ジャッジ日時 2023-10-20 19:06:17
合計ジャッジ時間 5,460 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 487 ms
12,064 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 11 ms
4,348 KB
testcase_06 AC 12 ms
4,348 KB
testcase_07 AC 9 ms
4,348 KB
testcase_08 AC 123 ms
5,356 KB
testcase_09 AC 424 ms
12,064 KB
testcase_10 AC 347 ms
12,064 KB
testcase_11 AC 9 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 1 ms
4,348 KB
testcase_17 AC 252 ms
8,176 KB
testcase_18 AC 615 ms
12,064 KB
権限があれば一括ダウンロードができます

ソースコード

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