結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー xxxasdfghjkxxxasdfghjk
提出日時 2018-09-10 19:49:07
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 41 ms / 1,000 ms
コード長 1,010 bytes
コンパイル時間 1,711 ms
コンパイル使用メモリ 148,312 KB
実行使用メモリ 5,720 KB
最終ジャッジ日時 2023-08-29 22:15:26
合計ジャッジ時間 5,498 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
5,520 KB
testcase_01 AC 40 ms
5,404 KB
testcase_02 AC 41 ms
5,576 KB
testcase_03 AC 39 ms
5,472 KB
testcase_04 AC 40 ms
5,464 KB
testcase_05 AC 40 ms
5,576 KB
testcase_06 AC 40 ms
5,700 KB
testcase_07 AC 41 ms
5,460 KB
testcase_08 AC 40 ms
5,516 KB
testcase_09 AC 40 ms
5,612 KB
testcase_10 AC 40 ms
5,688 KB
testcase_11 AC 41 ms
5,456 KB
testcase_12 AC 41 ms
5,408 KB
testcase_13 AC 41 ms
5,704 KB
testcase_14 AC 41 ms
5,720 KB
testcase_15 AC 40 ms
5,468 KB
testcase_16 AC 40 ms
5,708 KB
testcase_17 AC 41 ms
5,720 KB
testcase_18 AC 41 ms
5,460 KB
testcase_19 AC 41 ms
5,604 KB
testcase_20 AC 41 ms
5,404 KB
testcase_21 AC 40 ms
5,708 KB
testcase_22 AC 40 ms
5,652 KB
testcase_23 AC 40 ms
5,616 KB
testcase_24 AC 40 ms
5,692 KB
testcase_25 AC 40 ms
5,572 KB
testcase_26 AC 40 ms
5,704 KB
testcase_27 AC 40 ms
5,688 KB
testcase_28 AC 40 ms
5,616 KB
testcase_29 AC 39 ms
5,460 KB
testcase_30 AC 40 ms
5,516 KB
testcase_31 AC 40 ms
5,616 KB
testcase_32 AC 40 ms
5,648 KB
testcase_33 AC 40 ms
5,512 KB
testcase_34 AC 40 ms
5,568 KB
testcase_35 AC 41 ms
5,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};

vector<int> primes(0);
vector<bool> prime(5000001,true);
void erast(){
  prime[0] = false;
  prime[1] = false;
  for(int i=2;i<5000001;i++){
    if(prime[i]){
      primes.push_back(i);
      for(int j=i+i;j<5000001;j+=i){
        prime[j] = false;
      }
    }
  }
}
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  erast();
  ll N,L,a,cnt=0;
  cin >> N >> L;
  for(int i=0;i<primes.size();i++){
    a = L-(N-1)*primes[i];
    if (a >= 0){
      cnt += a+1;
    }
  }
  cout << cnt << endl;
  return 0;
}
0