結果

問題 No.6 使いものにならないハッシュ
ユーザー ninoinuininoinui
提出日時 2020-07-21 06:55:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 580 bytes
コンパイル時間 2,640 ms
コンパイル使用メモリ 203,756 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-10-14 23:25:49
合計ジャッジ時間 3,680 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
  int K, N;
  cin >> K >> N;
  vector<bool> B(N + 1, 1);
  B.at(0) = B.at(1) = 0;
  for (long i = 2; i <= N; i++) if (B.at(i)) for (long j = i * i; j <= N; j += i) B.at(j) = 0;
  vector<int> P;
  for (int i = K; i <= N; i++) if (B.at(i)) P.push_back(i);
  vector<int> V(9);
  int ans = 0;
  for (int l = 0, r = 0, b = 0, mx = 0; r < P.size(); r++) {
    if (++V.at(P.at(r) % 9) == 2) b = 1;
    while (b) if (--V.at(P.at(l++) % 9) == 1) b = 0;
    if (r - l >= mx) mx = r - l, ans = P.at(l);
  }
  cout << ans << "\n";
}
0