結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー alpha_virginisalpha_virginis
提出日時 2016-08-08 11:15:00
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 78 ms / 1,000 ms
コード長 1,082 bytes
コンパイル時間 1,446 ms
コンパイル使用メモリ 167,732 KB
実行使用メモリ 19,928 KB
最終ジャッジ日時 2023-08-22 04:55:19
合計ジャッジ時間 5,410 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
18,528 KB
testcase_01 AC 69 ms
19,192 KB
testcase_02 AC 70 ms
19,444 KB
testcase_03 AC 70 ms
18,236 KB
testcase_04 AC 69 ms
18,468 KB
testcase_05 AC 69 ms
18,480 KB
testcase_06 AC 70 ms
18,464 KB
testcase_07 AC 71 ms
18,728 KB
testcase_08 AC 73 ms
18,088 KB
testcase_09 AC 72 ms
18,084 KB
testcase_10 AC 71 ms
18,920 KB
testcase_11 AC 73 ms
18,444 KB
testcase_12 AC 74 ms
19,264 KB
testcase_13 AC 73 ms
19,016 KB
testcase_14 AC 70 ms
19,428 KB
testcase_15 AC 70 ms
18,392 KB
testcase_16 AC 68 ms
18,132 KB
testcase_17 AC 71 ms
18,664 KB
testcase_18 AC 74 ms
19,764 KB
testcase_19 AC 72 ms
18,464 KB
testcase_20 AC 76 ms
19,928 KB
testcase_21 AC 73 ms
18,920 KB
testcase_22 AC 72 ms
19,448 KB
testcase_23 AC 77 ms
18,796 KB
testcase_24 AC 78 ms
18,508 KB
testcase_25 AC 73 ms
18,088 KB
testcase_26 AC 73 ms
18,404 KB
testcase_27 AC 73 ms
18,536 KB
testcase_28 AC 73 ms
18,268 KB
testcase_29 AC 74 ms
19,324 KB
testcase_30 AC 73 ms
19,256 KB
testcase_31 AC 73 ms
18,728 KB
testcase_32 AC 70 ms
18,664 KB
testcase_33 AC 70 ms
18,468 KB
testcase_34 AC 73 ms
18,188 KB
testcase_35 AC 77 ms
18,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

template<typename T> T in() { abort(); return T(); }
template<> std::string in() { std::string str; std::cin >> str; return str; }
template<> int in() { int x; scanf("%d", &x); return x; }

template<typename T> void out(T x) { abort(); }
template<> void out(const char* x) { printf("%s\n", x); }
template<> void out(std::string x) { std::cout << x << std::endl; }
template<> void out(int x) { printf("%d\n", x); }
template<> void out(long x) { printf("%ld\n", x); }


std::vector<int> primes;
bool isnotprime[11234567];
void init() {
  isnotprime[0] = isnotprime[1] = true;
  for(int i = 2; i < 11234; ++i) {
    if( isnotprime[i] ) continue;
    for(int j = i + i; j < 11234567; j+=i) {
      isnotprime[j] = true;
    }
  }
  for(int i = 0; i < 11234567; ++i) {
    if( not isnotprime[i] ) {
      primes.push_back(i);
    }
  }
}      

int main() {
  init();
  auto n = in<int>();
  auto x = in<int>();

  long res = 0;
  for(int p : primes) {
    int t = x - (n - 1) * p;
    if( t < 0 ) break;
    res += t + 1;
  }

  out(res);    
  
  return 0;
}
0