結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー Bantako
提出日時 2017-07-27 23:32:54
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 276 ms / 1,000 ms
コード長 399 bytes
コンパイル時間 1,802 ms
コンパイル使用メモリ 156,892 KB
実行使用メモリ 42,752 KB
最終ジャッジ日時 2024-10-10 02:17:20
合計ジャッジ時間 10,864 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 31
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:3:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
    3 | main(){
      | ^~~~
main.cpp: In function ‘int main()’:
main.cpp:9:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |     scanf("%d%d",&N,&L);
      |     ~~~~~^~~~~~~~~~~~~~

ソースコード

diff #

#include<bits/stdc++.h>
int prime[10000000];
main(){
    for(int i = 2;i*i <=10000000;i++){
        if(prime[i])continue;
        for(int j = i*2;j < 10000000;j+=i)prime[j]=1;
    }
    int N,L;
    scanf("%d%d",&N,&L);
    long long sum = 0;
    for(int i = 2;i < 10000000;i++){
        if(prime[i])continue;
        if(i*(N-1)>L)break;
        sum += L-i*(N-1)+1;
    }
    printf("%lld\n",sum);
}
0