結果
問題 | No.1657 Sum is Prime (Easy Version) |
ユーザー |
![]() |
提出日時 | 2021-08-29 19:40:16 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 509 bytes |
コンパイル時間 | 1,517 ms |
コンパイル使用メモリ | 167,660 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-22 07:42:02 |
合計ジャッジ時間 | 16,315 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 1 TLE * 1 |
other | AC * 17 WA * 1 TLE * 3 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; bool is_prime(ll n) { 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; }