結果

問題 No.826 連絡網
ユーザー _____TAB__________TAB_____
提出日時 2019-05-03 21:57:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 533 bytes
コンパイル時間 641 ms
コンパイル使用メモリ 77,176 KB
実行使用メモリ 11,068 KB
最終ジャッジ日時 2023-08-30 06:07:54
合計ジャッジ時間 3,791 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 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,376 KB
testcase_07 WA -
testcase_08 AC 2 ms
4,376 KB
testcase_09 WA -
testcase_10 AC 1 ms
4,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 7 ms
4,380 KB
testcase_16 AC 61 ms
5,964 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 185 ms
9,472 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 46 ms
5,372 KB
testcase_23 AC 64 ms
6,016 KB
testcase_24 WA -
testcase_25 AC 240 ms
11,068 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 57 ms
5,684 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int minimum_prime_factor(int x){
  for(int i = 2; i*i <= x; ++i){
    if(x%i) continue;
    return i;
  }
  return x;
}

int main(){
  int N, P;
  cin >> N >> P;
  if(P == 1){
    cout << 1 << endl;
    return 0;
  }
  int ans = 0;
  vector<long long> D(N);
  for(int i = 0; i < N; ++i){
    D[i] = minimum_prime_factor(i+1);
  }
  for(int i = 1; i < N; ++i){
    if(D[i] == D[P-1] or D[i]*D[P-1] <= N){
      ++ans;
    }
  }
  cout << ans << endl;
}
0