結果
問題 |
No.1657 Sum is Prime (Easy Version)
|
ユーザー |
![]() |
提出日時 | 2021-08-29 19:42:58 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 544 bytes |
コンパイル時間 | 1,513 ms |
コンパイル使用メモリ | 167,160 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-22 07:44:14 |
合計ジャッジ時間 | 16,062 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 TLE * 1 |
other | AC * 18 TLE * 3 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; bool is_prime(ll n) { if (n == 1) return false; for (ll i = 2; i * i <= n; i++) { if (n%i == 0) { return false; } } return true; } int main() { ll l, r; int ans = 0; scanf("%lld %lld", &l, &r); for (ll i = l; i <= r; i++) { if (is_prime(i)) { ans++; } if (i+1 <= r && is_prime(i+i+1)) { ans++; } } printf("%d\n", ans); return 0; }