結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー Y17Y17
提出日時 2018-10-07 19:20:49
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 106 ms / 1,000 ms
コード長 464 bytes
コンパイル時間 1,243 ms
コンパイル使用メモリ 143,860 KB
実行使用メモリ 13,384 KB
最終ジャッジ日時 2023-08-02 18:07:32
合計ジャッジ時間 6,305 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
13,160 KB
testcase_01 AC 90 ms
13,084 KB
testcase_02 AC 91 ms
13,100 KB
testcase_03 AC 91 ms
13,288 KB
testcase_04 AC 90 ms
13,084 KB
testcase_05 AC 106 ms
13,200 KB
testcase_06 AC 98 ms
13,164 KB
testcase_07 AC 90 ms
13,156 KB
testcase_08 AC 89 ms
13,168 KB
testcase_09 AC 90 ms
13,200 KB
testcase_10 AC 90 ms
13,096 KB
testcase_11 AC 90 ms
13,084 KB
testcase_12 AC 89 ms
13,068 KB
testcase_13 AC 89 ms
13,072 KB
testcase_14 AC 89 ms
13,068 KB
testcase_15 AC 89 ms
13,184 KB
testcase_16 AC 92 ms
13,048 KB
testcase_17 AC 93 ms
13,160 KB
testcase_18 AC 89 ms
13,288 KB
testcase_19 AC 90 ms
13,068 KB
testcase_20 AC 95 ms
13,140 KB
testcase_21 AC 93 ms
13,124 KB
testcase_22 AC 91 ms
13,136 KB
testcase_23 AC 91 ms
13,384 KB
testcase_24 AC 91 ms
13,112 KB
testcase_25 AC 94 ms
13,196 KB
testcase_26 AC 95 ms
13,124 KB
testcase_27 AC 88 ms
13,236 KB
testcase_28 AC 91 ms
13,072 KB
testcase_29 AC 97 ms
13,160 KB
testcase_30 AC 90 ms
13,248 KB
testcase_31 AC 94 ms
13,048 KB
testcase_32 AC 95 ms
13,096 KB
testcase_33 AC 103 ms
13,108 KB
testcase_34 AC 106 ms
13,096 KB
testcase_35 AC 105 ms
13,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

bool memo[10000010];

int main(){
  int n, l;
  cin >> n >> l;
  memset(memo,true,sizeof(memo));
  memo[1] = false;

  for(int i = 2;i < 10000010;i++){
    if(memo[i]){
      for(int j = i*2; j < 10000010;j+=i){
        memo[j] = false;
      }
    }
  }

  long long ans = 0;
  for(int i = 2;i <= l;i++){
    if(memo[i]){
      ans += max(l-(long long)i*(n-1)+1, 0ll);
    }
  }
  cout << ans << endl;
  return 0;
}
0