結果

問題 No.713 素数の和
ユーザー nasu_ysmrnasu_ysmr
提出日時 2018-10-30 14:25:46
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 511 bytes
コンパイル時間 2,122 ms
コンパイル使用メモリ 28,384 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-12 10:22:00
合計ジャッジ時間 975 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <stdio.h>

int primenumber(int M)
{
    int i=2;
    if(M==2||M==3) return 1;
    while(1){
        if( M%i==0 || M==1 ){
            return 0;
            break;
        }
        i=i+1;
        if(M < i*i){
            return 1;
            break;
        }
    }
    return 0;
}

int main(){
    int N;
    int M;
    int sum=0;
    scanf("%d", &N);
    for(M=1; M<=N; M++){
        if(primenumber(M)==1){
            sum += M;
        }
    }
    printf("%d", sum);
}
0