結果
| 問題 | No.407 鴨等素数間隔列の数え上げ |
| コンテスト | |
| ユーザー |
okayunonaha
|
| 提出日時 | 2016-08-06 01:19:16 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 83 ms / 1,000 ms |
| コード長 | 600 bytes |
| 記録 | |
| コンパイル時間 | 296 ms |
| コンパイル使用メモリ | 39,168 KB |
| 実行使用メモリ | 13,824 KB |
| 最終ジャッジ日時 | 2026-05-26 05:43:30 |
| 合計ジャッジ時間 | 2,703 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 31 |
ソースコード
#include <cstdio>
using namespace std;
bool x[10000010];
void sosu(int n, int l) {
for (int i = 2; i <= l; i++) {
if(!x[i]){
for (int j = 2; i*j <= l; j++) {
x[i * j] = true;
}
}
}
/*for (int i = 2; i <= l; i++) {
if(!x[i]) cout << i << " ";
}
cout << endl;
*/
}
int main(void) {
long long int tmp, N, L, d, round = 0, ans = 1;
scanf("%Ld %Ld", &N, &L);
sosu(N,L);
for (int i = 2; ; i++) {
if(!x[i]){ d = i;
tmp = (i-1) * (N-1)+N;
if(tmp > L+1) break;
else tmp = L+1 - tmp + 1;
round += tmp;
}
}
printf("%Ld\n", round);
//else cout << 0 << endl;
return 0;
}
okayunonaha