結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー konsin_tokage
提出日時 2018-05-30 12:40:38
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 212 ms / 1,000 ms
コード長 306 bytes
コンパイル時間 491 ms
コンパイル使用メモリ 58,968 KB
実行使用メモリ 42,088 KB
最終ジャッジ日時 2024-06-30 08:12:09
合計ジャッジ時間 2,984 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
#define ll long long int
int main(){
    ll n,l,r=0;
    cin>>n>>l;
    vector<int> s(l,1);
    for(int i=2;i*i<l;++i)if(s[i])for(int j=i+i;j<l;j+=i)s[j]=0;
    for(ll i=2;i<l;++i)if(s[i])r+=max(0LL,l-i*(n-1)+1);
    cout<<r<<endl;
    return 0;
}
0