結果
| 問題 | 
                            No.1657 Sum is Prime (Easy Version)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2021-08-27 21:27:40 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 17 ms / 2,000 ms | 
| コード長 | 323 bytes | 
| コンパイル時間 | 622 ms | 
| コンパイル使用メモリ | 64,072 KB | 
| 実行使用メモリ | 5,504 KB | 
| 最終ジャッジ日時 | 2024-11-21 00:51:13 | 
| 合計ジャッジ時間 | 1,666 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 21 | 
コンパイルメッセージ
main.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main()
      | ^~~~
            
            ソースコード
#include<iostream>
using namespace std;
int L,R;
bool isp[2<<20];
main()
{
	isp[1]=true;
	for(int i=2;i<2<<20;i++)if(!isp[i])
	{
		for(int j=i+i;j<2<<20;j+=i)isp[j]=true;
	}
	cin>>L>>R;
	int ans=0;
	for(int a=L;a<=R;a++)
	{
		if(!isp[a])
		{
			ans++;
		}
		if(a+1<=R&&!isp[a+a+1])
		{
			ans++;
		}
	}
	cout<<ans<<endl;
}