結果
| 問題 |
No.407 鴨等素数間隔列の数え上げ
|
| コンテスト | |
| ユーザー |
RIGIH
|
| 提出日時 | 2017-06-28 14:26:09 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 637 bytes |
| コンパイル時間 | 443 ms |
| コンパイル使用メモリ | 59,264 KB |
| 実行使用メモリ | 29,620 KB |
| 最終ジャッジ日時 | 2024-10-04 14:45:47 |
| 合計ジャッジ時間 | 5,572 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 27 TLE * 2 -- * 2 |
ソースコード
#include<stdio.h>
#include <iostream>
#include <cstring>
#include <math.h>
using namespace std;
int main(){
long long n,a;
cin>>n>>a;
int x=a/(n-1);
long ds=0;
int z=0;
int *s;
s=new int[x];
for(int i=0;i<x;i++){
s[i]=1;
}
s[0]=0;
for(int i=0;i*i<=x;i++){
if(s[i]==1){
for(int j=i+1;j<x;j++){
if( s[j]==1 && (j+1)%(i+1) == 0){
s[j]=0;
//cout<<j+1<<"が素数でないと判定されました"<<"j+1="<<j+1<<"i+1="<<i+1<<endl;
}
}
}
}
for(int i=0;i<x;i++){
if(s[i]==1){
z++;
ds+=i+1;
}
}
cout<<(a+1)*z-(n-1)*ds<<endl;
return 0;
}
RIGIH