結果

問題 No.713 素数の和
ユーザー sggkshiosggkshio
提出日時 2019-01-07 00:43:44
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 742 bytes
コンパイル時間 571 ms
コンパイル使用メモリ 83,464 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-15 16:23:28
合計ジャッジ時間 1,498 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>
#include <fstream>
#include <cassert>
//#include <bits/stdc++.h>
using namespace std;

//#include<bits/stdc++.h>

bool f[1002];
	
int main() {

	for (int i = 3; i <= 1000; i+=2) {
		f[i] = 1;
		for (int j = 3; j*j <= i; j += 2) {
			if (i%j == 0) {
				f[i] = 0; break;
			}
			}

	}
	f[2] = 1;
	int n;
	cin >> n;
	int r = 0;
	for (int i = 2; i <= n; i++)if (f[i])r += i;
	cout << r << endl;
	
	return 0;
}
0