結果

問題 No.1657 Sum is Prime (Easy Version)
ユーザー snrnsidysnrnsidy
提出日時 2021-10-22 21:10:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 776 ms / 2,000 ms
コード長 485 bytes
コンパイル時間 1,987 ms
コンパイル使用メモリ 201,220 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 11:50:44
合計ジャッジ時間 7,408 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 688 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 3 ms
4,348 KB
testcase_12 AC 643 ms
4,348 KB
testcase_13 AC 232 ms
4,348 KB
testcase_14 AC 321 ms
4,348 KB
testcase_15 AC 421 ms
4,348 KB
testcase_16 AC 97 ms
4,348 KB
testcase_17 AC 19 ms
4,348 KB
testcase_18 AC 49 ms
4,348 KB
testcase_19 AC 645 ms
4,348 KB
testcase_20 AC 173 ms
4,348 KB
testcase_21 AC 776 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 86 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0