結果
問題 | No.843 Triple Primes |
ユーザー |
![]() |
提出日時 | 2019-06-28 21:38:49 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 619 bytes |
コンパイル時間 | 2,187 ms |
コンパイル使用メモリ | 198,280 KB |
最終ジャッジ日時 | 2025-01-07 05:26:09 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 TLE * 1 |
other | AC * 24 TLE * 18 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:25:20: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 2 has type ‘int64_t’ {aka ‘long int’} [-Wformat=] 25 | printf("%lld\n", count); | ~~~^ ~~~~~ | | | | | int64_t {aka long int} | long long int | %ld main.cpp:6:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 6 | scanf("%d", &N); | ~~~~~^~~~~~~~~~
ソースコード
#include <bits/stdc++.h> int main() { int N; scanf("%d", &N); std::vector<bool> isPrime(N + 1, true); std::vector<int64_t> primeList; isPrime[0] = isPrime[1] = false; for (int64_t i{2}; i <= N; i++) { if (!isPrime[i]) continue; primeList.push_back(i); for (int64_t j{2 * i}; j <= N; j += i) isPrime[j] = false; } int64_t count{}; for (int p_i{}; p_i < (int)primeList.size(); p_i++) for (int r_i{}; r_i < (int)primeList.size(); r_i++) { int64_t q{primeList[r_i] * primeList[r_i] - primeList[p_i]}; if (2 <= q && q <= N && isPrime[q]) count++; } printf("%lld\n", count); return 0; }