結果
| 問題 | No.843 Triple Primes |
| コンテスト | |
| ユーザー |
a
|
| 提出日時 | 2019-06-29 22:33:32 |
| 言語 | C++14 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 1 ms / 2,000 ms |
| + 399µs | |
| コード長 | 433 bytes |
| 記録 | |
| コンパイル時間 | 871 ms |
| コンパイル使用メモリ | 180,204 KB |
| 実行使用メモリ | 9,792 KB |
| 最終ジャッジ日時 | 2026-08-31 02:59:17 |
| 合計ジャッジ時間 | 2,916 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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