結果
問題 | No.713 素数の和 |
ユーザー | akakimidori |
提出日時 | 2018-07-13 22:27:35 |
言語 | C90 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 538 bytes |
コンパイル時間 | 126 ms |
コンパイル使用メモリ | 23,168 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-04-20 04:41:31 |
合計ジャッジ時間 | 616 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 0 ms
5,376 KB |
testcase_02 | AC | 0 ms
5,376 KB |
testcase_03 | AC | 1 ms
5,376 KB |
testcase_04 | AC | 1 ms
5,376 KB |
testcase_05 | AC | 1 ms
5,376 KB |
testcase_06 | AC | 0 ms
5,376 KB |
testcase_07 | AC | 1 ms
5,376 KB |
testcase_08 | AC | 1 ms
5,376 KB |
コンパイルメッセージ
main.c: In function ‘run’: main.c:25:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 25 | scanf("%d",&n); | ^~~~~~~~~~~~~~
ソースコード
#include<stdio.h> #include<stdlib.h> #include<math.h> typedef long long int int64; #define MAX(a,b) ((a)>(b)?(a):(b)) #define MIN(a,b) ((a)<(b)?(a):(b)) #define ABS(a) ((a)>(0)?(a):-(a)) int isPrime(int n){ if(n<=1) return 0; if(n<=3) return 1; if(n%2==0) return 0; int k=3; while(k*k<=n){ if(n%k==0) return 0; k+=2; } return 1; } void run(void){ int n; scanf("%d",&n); int sum=0; int i; for(i=1;i<=n;i++) if(isPrime(i)) sum+=i; printf("%d\n",sum); } int main(void){ run(); return 0; }