結果
| 問題 |
No.407 鴨等素数間隔列の数え上げ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-08-27 13:16:22 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 90 ms / 1,000 ms |
| コード長 | 412 bytes |
| コンパイル時間 | 1,538 ms |
| コンパイル使用メモリ | 168,176 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-14 11:17:04 |
| 合計ジャッジ時間 | 3,420 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
}