結果
| 問題 | No.407 鴨等素数間隔列の数え上げ |
| コンテスト | |
| ユーザー |
kpinkcat
|
| 提出日時 | 2023-12-11 02:33:54 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 634 bytes |
| 記録 | |
| コンパイル時間 | 646 ms |
| コンパイル使用メモリ | 128,760 KB |
| 実行使用メモリ | 81,664 KB |
| 最終ジャッジ日時 | 2026-07-03 05:53:10 |
| 合計ジャッジ時間 | 10,364 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 5 |
| other | WA * 27 TLE * 4 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:30:40: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
30 | if ((l - max + 1) > 0) ans += (l - max + 1);
| ~~~~^~~~~~~~~~~~~~~~
main.cpp:17:8: note: 'ans' was declared here
17 | ll ans;
| ^~~
ソースコード
#include<iostream>
#include<string>
#include<algorithm>
#include<cctype>
#include<set>
#include<bitset>
#include<math.h>
#include<map>
#include<queue>
#include<iomanip>
using namespace std;
using ll = long long;
int main()
{
ll n, l, max = 0;
ll ans;
cin >> n >> l;
vector<ll> p(l+1, 1);
p[0] = 0;
p[1] = 0;
for (int i = 2; i <= l; i++){
for (int j = i*2; j <= l; j += i){
p[j] = 0;
}
}
for (ll i = 2; i*(n-1) <= l; i++){
if (p[i]) {
max = i*(n-1);
if ((l - max + 1) > 0) ans += (l - max + 1);
}
}
cout << ans << endl;
}
kpinkcat