結果
問題 | No.713 素数の和 |
ユーザー |
![]() |
提出日時 | 2018-10-12 04:33:44 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 362 bytes |
コンパイル時間 | 1,693 ms |
コンパイル使用メモリ | 192,624 KB |
最終ジャッジ日時 | 2025-01-06 14:31:18 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 |
ソースコード
#include<bits/stdc++.h>typedef long long ll;using namespace std;ll prime(ll x) {ll i;if (x < 2)return 0;else if (x == 2) return 1;if (x % 2 == 0) return 0;for (i = 3; i*i <= x; i += 2) {if (x%i == 0) return 0;}return 1;}int main(){int N;cin>>N;int sum=0;for(ll i=2; i<=N; i++){if(prime(i)){sum+=i;}}cout<<sum<<endl;}