結果
| 問題 | No.407 鴨等素数間隔列の数え上げ |
| コンテスト | |
| ユーザー |
ikd
|
| 提出日時 | 2016-08-05 23:14:56 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 641 bytes |
| 記録 | |
| コンパイル時間 | 883 ms |
| コンパイル使用メモリ | 60,480 KB |
| 実行使用メモリ | 42,556 KB |
| 最終ジャッジ日時 | 2024-11-07 01:40:25 |
| 合計ジャッジ時間 | 3,320 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 18 WA * 13 |
ソースコード
#include<iostream>
#include<math.h>
using namespace std;
int arr[10000000];
void Eratosthenes(int N){
for(int i=0; i<N; i++){
arr[i]=1;
}
for(int i=2; i<sqrt(N); i++){
if(arr[i]){
for(int j=0; i*(j + 2)<N; j++){
arr[i*(j+2)]=0;
}
}
}
/*
for(int i = 2; i < N; i++){
if(arr[i]){
//cout << i << endl;
}
}
*/
arr[1]=0;
arr[0]=-1;
}
int main(){
int N, L;
cin>> N>> L;
Eratosthenes(L);
long long ans=0;
for(int i=2; i<=L; i++){
if(arr[i]==0) continue;
int mi=(N-1)*i;
if(mi>L) continue;
ans=ans+(L-mi+1);
}
cout<< ans<< endl;
return 0;
}
ikd