結果
| 問題 |
No.1657 Sum is Prime (Easy Version)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-10-22 21:10:32 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 854 ms / 2,000 ms |
| コード長 | 485 bytes |
| コンパイル時間 | 2,434 ms |
| コンパイル使用メモリ | 191,652 KB |
| 最終ジャッジ日時 | 2025-01-25 03:03:58 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
cin.tie(0);
ios::sync_with_stdio(false);
int L,R;
int res = 0;
cin >> L >> R;
for(int i=L;i<=R;i++)
{
int sum = 0;
for(int j=0;j<5;j++)
{
int x = i + j;
if(x > R) break;
sum += x;
if(sum==1) continue;
bool ok = true;
int m = sqrt(sum);
for(int k=2;k<=m;k++)
{
if(sum%k==0)
{
ok = false;
break;
}
}
res += ok;
}
}
cout << res << '\n';
return 0;
}