結果

問題 No.713 素数の和
ユーザー MSKMSK
提出日時 2018-10-01 20:45:33
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 414 bytes
コンパイル時間 707 ms
コンパイル使用メモリ 62,188 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 14:20:57
合計ジャッジ時間 1,252 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

bool isPrime(int n){
  if(1 == n) return false;
  if(2 == n) return true;
  for(int i = 2; i <= sqrt(n); i++){
    if(0 == n % i) return false;

  }
  return true;

}

int main(void){
  int N; 
  cin >> N;
  int ans = 0;
  for(int i = 1; i <= N; i++){
    if(isPrime(i)){
      ans += i;

    }
  } 
  cout << ans << endl;
  return 0;

}
0