結果
問題 | No.713 素数の和 |
ユーザー |
![]() |
提出日時 | 2018-10-08 12:19:19 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,525 bytes |
コンパイル時間 | 726 ms |
コンパイル使用メモリ | 97,724 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-12 14:30:23 |
合計ジャッジ時間 | 1,229 ms |
ジャッジサーバーID (参考情報) |
judge / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 |
ソースコード
#include <iostream>#include <vector>#include <algorithm>#include <string>#include <map>#include <cmath>#include <queue>#include <numeric>#include <climits>#include <iterator>#include <iomanip>#include <stack>#include <set>#include <cstdio>#include <bitset>#include <functional>#include <tuple>#include <list>#include <deque>#include <sstream>using namespace std;const constexpr int INF = 1e9;#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)#define REP(i, n) FOR(i, 0, n)typedef long long ll;typedef vector<int> VI;typedef pair<ll, ll> P;struct Less{bool operator()(const pair<string, int>&a, const pair<string, int>&b){if(a.first==b.first){return a.second < b.second;}return a.first < b.first;}};const constexpr ll MOD = 1e9;ll extGCD(ll a, ll b, ll& x, ll& y){if(b==0){x=1;y=0;return a;}ll d = extGCD(b, a%b, y, x);y -= a/b*x;return d;}ll GCD(ll a, ll b){if(a<b) swap(a, b);if(b==0) return a;return GCD(b, a%b);}bool sieve[1010];int main() {for(int i=0; i<1010; ++i) sieve[i]=true;sieve[0]=sieve[1]=false;cin.tie(0);ios::sync_with_stdio(false);for(int i=2; i*i<1010; ++i){if(sieve[i]){for(int j=2; i*j<1010; ++j){sieve[i*j]=false;}}}int N; cin >> N;int ans=0;for(int i=0; i<=N; ++i){if(sieve[i]) ans+=i;}cout << ans << endl;return 0;}