結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー algon_320algon_320
提出日時 2016-08-05 23:29:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,278 bytes
コンパイル時間 1,528 ms
コンパイル使用メモリ 165,380 KB
実行使用メモリ 54,632 KB
最終ジャッジ日時 2024-04-24 19:06:57
合計ジャッジ時間 10,812 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define FORE(x,arr) for(auto &x:arr)
#define REP(v,n) FOR(v,0,n)
#define ALL(c) begin(c),end(c)
const int DX[4]={0,1,0,-1}, DY[4]={-1,0,1,0};
const int INF = 1e9;
template<class T,class U>ostream&operator<<(ostream &os,const pair<T,U> &p){
    os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T>ostream&operator<<(ostream &os,const vector<T> &v){
    ITR(i,v)os<<*i<<(i==end(v)-1?"":" ");return os;}
//-----------------------------------------------------------

ll table[6000000];
vector<ll> prime;
void init() {
    fill(ALL(table),-1);
    for(ll i=2; i<6000000; i++) {
        if(table[i]!=0) {
            table[i]=0;
            prime.push_back(i);
            for(ll j=2; i*j<6000000; j++) {
                table[i*j]=0;
            }
        }
    }
}
int main(int argc, char const *argv[]) {
    ll N,L;
    cin>>N>>L;
    init();
    cout<<prime[prime.size()-1]<<endl;
    ll ans=0;
    for(ll i=0; prime[i]<=L/2+1; i++) {
        ll d=prime[i];
        ll a;
        for(a=0; a+(N-1)*d<=L; a++);
        ans+=a;
    }
    cout<<ans<<endl;
    return 0;
}


0