結果
| 問題 |
No.843 Triple Primes
|
| コンテスト | |
| ユーザー |
a
|
| 提出日時 | 2019-06-29 22:33:32 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 433 bytes |
| コンパイル時間 | 1,665 ms |
| コンパイル使用メモリ | 167,688 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-19 14:14:44 |
| 合計ジャッジ時間 | 2,909 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 42 |
ソースコード
#include "bits/stdc++.h"
using namespace std;
bool isPrime(int x)
{
for (int i = 2; i*i <= x; i++)
{
if (x % i == 0) return false;
}
return true;
}
void solve(void)
{
int n;
cin >> n;
int ans = 0;
for (int i = 2; i * i <= n+2; i++)
{
if (isPrime(i) && isPrime(i*i-2))
{
if (i == 2) ans++;
else ans += 2;
}
}
cout << ans << endl;
}
int main()
{
solve();
//cout << "yui(*-v・)yui" << endl;
return 0;
}
a