結果
| 問題 | No.407 鴨等素数間隔列の数え上げ |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-08-27 13:16:22 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 39 ms / 1,000 ms |
| コード長 | 412 bytes |
| 記録 | |
| コンパイル時間 | 1,133 ms |
| コンパイル使用メモリ | 181,996 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-05-01 20:35:54 |
| 合計ジャッジ時間 | 3,053 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 31 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
int N, L;
ll ans = 0;
cin >> N >> L;
vector<bool> tb(L + 1, true);
for(int i = 2; i <= L && i * (N - 1) <= L; i++){
if(!tb[i])continue;
ll l = i * (N - 1);
ans += L - l + 1;
for(int j = 2 * i; j <= L; j += i){
tb[j] = false;
}
}
cout << ans << endl;
}