結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー Y17Y17
提出日時 2018-10-07 19:20:49
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 112 ms / 1,000 ms
コード長 464 bytes
コンパイル時間 1,398 ms
コンパイル使用メモリ 158,368 KB
実行使用メモリ 13,284 KB
最終ジャッジ日時 2024-04-20 18:17:12
合計ジャッジ時間 6,164 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
13,056 KB
testcase_01 AC 98 ms
13,056 KB
testcase_02 AC 93 ms
13,056 KB
testcase_03 AC 104 ms
13,056 KB
testcase_04 AC 96 ms
13,184 KB
testcase_05 AC 112 ms
13,236 KB
testcase_06 AC 98 ms
13,056 KB
testcase_07 AC 93 ms
13,236 KB
testcase_08 AC 96 ms
13,184 KB
testcase_09 AC 92 ms
13,184 KB
testcase_10 AC 97 ms
13,184 KB
testcase_11 AC 96 ms
13,056 KB
testcase_12 AC 100 ms
13,172 KB
testcase_13 AC 105 ms
13,168 KB
testcase_14 AC 97 ms
13,056 KB
testcase_15 AC 97 ms
13,056 KB
testcase_16 AC 101 ms
13,184 KB
testcase_17 AC 98 ms
13,284 KB
testcase_18 AC 99 ms
13,184 KB
testcase_19 AC 97 ms
13,056 KB
testcase_20 AC 101 ms
13,084 KB
testcase_21 AC 102 ms
13,128 KB
testcase_22 AC 98 ms
13,184 KB
testcase_23 AC 100 ms
13,184 KB
testcase_24 AC 97 ms
13,184 KB
testcase_25 AC 105 ms
13,088 KB
testcase_26 AC 99 ms
13,068 KB
testcase_27 AC 92 ms
13,056 KB
testcase_28 AC 94 ms
13,184 KB
testcase_29 AC 100 ms
13,184 KB
testcase_30 AC 98 ms
13,148 KB
testcase_31 AC 97 ms
13,184 KB
testcase_32 AC 97 ms
13,180 KB
testcase_33 AC 106 ms
13,184 KB
testcase_34 AC 105 ms
13,184 KB
testcase_35 AC 104 ms
13,184 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