結果

問題 No.1946 ロッカーの問題
ユーザー tnakao0123tnakao0123
提出日時 2022-05-20 23:35:10
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 240 ms / 3,000 ms
コード長 670 bytes
コンパイル時間 304 ms
コンパイル使用メモリ 41,632 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 14:31:12
合計ジャッジ時間 2,336 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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