結果

問題 No.826 連絡網
ユーザー pekempeypekempey
提出日時 2019-05-03 21:29:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 597 bytes
コンパイル時間 588 ms
コンパイル使用メモリ 72,524 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-30 05:56:30
合計ジャッジ時間 2,978 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
4,380 KB
testcase_07 WA -
testcase_08 AC 2 ms
4,380 KB
testcase_09 WA -
testcase_10 AC 1 ms
4,380 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 7 ms
4,380 KB
testcase_16 AC 38 ms
4,376 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 90 ms
4,380 KB
testcase_21 AC 3 ms
4,376 KB
testcase_22 AC 30 ms
4,376 KB
testcase_23 AC 39 ms
4,380 KB
testcase_24 WA -
testcase_25 AC 109 ms
4,376 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 35 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

int main() {
  int N, P;
  cin >> N >> P;
  vector<bool> can(N+1);
  can[P] = true;
  for (int ii = 0; ii < 2; ii++) {
    for (int i = N; i >= 2; i--) {
      for (int j = i*2; j <= N; j += i) {
        can[i] = can[i] || can[j];
      }
    }
    for (int i = 2; i <= N; i++) {
      for (int j = i*2; j <= N; j += i) {
        can[j] = can[j] || can[i];
      }
    }
  }
  int ans = count(can.begin(), can.end(), true);
  cout << ans << '\n';
}
0