結果

問題 No.713 素数の和
ユーザー sigmanisigmani
提出日時 2022-02-10 13:49:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 604 bytes
コンパイル時間 855 ms
コンパイル使用メモリ 97,416 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-08 02:57:24
合計ジャッジ時間 1,511 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<bitset>
#include <vector>
#include<bitset>
#include <iomanip>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <climits>
#include <queue>
using namespace std;

int main() {
	map<int, int> Prime;
	for (int i = 2; i <= 1000; i++) {
		int D = pow(i, 0.5);
		int count = 0;
		for (int j = 2; j <= D; j++) {
			if (i % j == 0)count++;
		}
		if (count == 0)Prime[i]++;
	}
	int N;
	cin >> N;
	int answer = 0;
	for (int i = 2; i <= N; i++) {
		if (Prime[i] > 0)answer=answer+i;
    }
	cout << answer;
   
}
0