結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー itezpaceitezpace
提出日時 2016-08-05 23:58:09
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 52 ms / 1,000 ms
コード長 591 bytes
コンパイル時間 1,748 ms
コンパイル使用メモリ 146,480 KB
実行使用メモリ 24,632 KB
最終ジャッジ日時 2023-08-22 04:26:59
合計ジャッジ時間 3,747 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,388 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,384 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 7 ms
5,412 KB
testcase_20 AC 15 ms
9,472 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 24 ms
13,948 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 12 ms
8,584 KB
testcase_33 AC 50 ms
24,632 KB
testcase_34 AC 52 ms
24,560 KB
testcase_35 AC 21 ms
13,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

vector<int> v;

void eratos(int a){
  int arr[a+1];
  for(int i=0; i<a+1; ++i){
    arr[i]=1;
  }
  arr[0]=0;
  arr[1]=0;
  for(int i=2; i*i<a+1; ++i){
    if(arr[i]==1){
      for(int j=0; i*(j+2)<a+1; j++){
        arr[i*(j+2)]=0;
      }
    }
  }
  for(int i=2; i<a+1; ++i){
    if(arr[i]==1){
      v.push_back(i);
    }
  }
}

int main(){
  int n,l,a;
  cin>>n>>l;
  a=l/(n-1);
  eratos(a);
  int vs;
  vs=v.size();
  ll x;
  x=0;
  for(int i=0; i<vs; ++i){
    x+=l-v[i]*(n-1)+1;
  }
  cout<<x<<endl;
  return 0;
}
0