結果

問題 No.1946 ロッカーの問題
ユーザー tnakao0123
提出日時 2022-05-20 23:35:10
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 241 ms / 3,000 ms
コード長 670 bytes
コンパイル時間 310 ms
コンパイル使用メモリ 41,472 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-20 10:01:02
合計ジャッジ時間 2,058 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 1946.cc:  No.1946 ロッカーの問題 - yukicoder
 */

#include<cstdio>
#include<algorithm>
 
using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

/* global variables */

int rs[MAX_N + 1];

/* subroutines */

/* main */

int main() {
  int n, m;
  scanf("%d%d", &n, &m);

  for (int i = 0; i < m; i++) {
    int ai;
    scanf("%d", &ai);
    rs[ai] = 1;
  }

  int c = 0;
  for (int i = n; i >= 1; i--) {
    if (rs[i]) {
      for (int p = 1; p * p <= i; p++)
	if (i % p == 0) {
	  int q = i / p;
	  rs[p] ^= 1;
	  if (q != p) rs[q] ^= 1;
	}
    }
    else
      c++;
  }

  printf("%d\n", c);
  return 0;
}
0