結果

問題 No.713 素数の和
ユーザー hiro_ei1812hiro_ei1812
提出日時 2019-09-14 18:47:21
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 493 bytes
コンパイル時間 396 ms
コンパイル使用メモリ 52,132 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-20 14:23:39
合計ジャッジ時間 983 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 WA -
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#define True 1
int sosuu(int N);
using namespace std;

int main(){
    int N;
    int i,ans=2;
    
    cin>>N;   //N以下の素数の範囲を示す

    if(N<=2){
        cout<<"2"<<endl;
        return(0);
    }

    for(i=3;i<=N;i+=2){
        if(sosuu(i)==0){
            ans+=i;
        }
    }
    cout<<ans<<endl;

    return(0);
}

int sosuu(int N){
    int k;
    int n=0;

    for(k=3;k<=N && (N%k)!=0;k+=2);

    if(N<=k) return n ;
    else     return n+1;
}
0