結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー toto6114toto6114
提出日時 2020-04-06 17:11:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 44 ms / 1,000 ms
コード長 969 bytes
コンパイル時間 839 ms
コンパイル使用メモリ 103,476 KB
実行使用メモリ 8,460 KB
最終ジャッジ日時 2023-09-20 18:42:18
合計ジャッジ時間 3,942 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
8,284 KB
testcase_01 AC 36 ms
8,264 KB
testcase_02 AC 35 ms
8,236 KB
testcase_03 AC 36 ms
8,460 KB
testcase_04 AC 35 ms
8,252 KB
testcase_05 AC 35 ms
8,460 KB
testcase_06 AC 35 ms
8,396 KB
testcase_07 AC 35 ms
8,264 KB
testcase_08 AC 34 ms
8,288 KB
testcase_09 AC 34 ms
8,264 KB
testcase_10 AC 34 ms
8,276 KB
testcase_11 AC 34 ms
8,276 KB
testcase_12 AC 35 ms
8,392 KB
testcase_13 AC 35 ms
8,320 KB
testcase_14 AC 34 ms
8,236 KB
testcase_15 AC 35 ms
8,236 KB
testcase_16 AC 35 ms
8,280 KB
testcase_17 AC 36 ms
8,344 KB
testcase_18 AC 35 ms
8,228 KB
testcase_19 AC 35 ms
8,240 KB
testcase_20 AC 37 ms
8,332 KB
testcase_21 AC 35 ms
8,268 KB
testcase_22 AC 34 ms
8,312 KB
testcase_23 AC 35 ms
8,252 KB
testcase_24 AC 35 ms
8,336 KB
testcase_25 AC 40 ms
8,276 KB
testcase_26 AC 34 ms
8,284 KB
testcase_27 AC 35 ms
8,236 KB
testcase_28 AC 34 ms
8,288 KB
testcase_29 AC 35 ms
8,284 KB
testcase_30 AC 34 ms
8,232 KB
testcase_31 AC 35 ms
8,316 KB
testcase_32 AC 37 ms
8,264 KB
testcase_33 AC 44 ms
8,284 KB
testcase_34 AC 43 ms
8,232 KB
testcase_35 AC 39 ms
8,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  bool f[5000001]={};
  for(int i=2; i<=5000000; i++) {
    if(!f[i]) {
      for(int j=i*2; j<=5000000; j+=i) {
        f[j]=true;
      }
    }
  }
  ll n,l,ans=0,x;
  cin >> n >> l;
  x=l/(n-1);
  for(int i=2; i<=x; i++) {
    if(!f[i]) {
      ans+=l-i*(n-1)+1;
    }
  }
  cout << ans << endl;
}
0