結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー kpinkcatkpinkcat
提出日時 2023-12-11 02:33:54
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 634 bytes
コンパイル時間 1,088 ms
コンパイル使用メモリ 108,236 KB
実行使用メモリ 81,420 KB
最終ジャッジ日時 2023-12-11 02:34:11
合計ジャッジ時間 16,514 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 40 ms
10,832 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 TLE -
testcase_06 AC 856 ms
44,240 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 3 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 45 ms
11,108 KB
testcase_20 AC 349 ms
26,732 KB
testcase_21 AC 59 ms
13,616 KB
testcase_22 AC 46 ms
11,744 KB
testcase_23 AC 150 ms
18,388 KB
testcase_24 AC 375 ms
26,732 KB
testcase_25 AC 840 ms
42,356 KB
testcase_26 AC 829 ms
42,356 KB
testcase_27 AC 29 ms
8,872 KB
testcase_28 AC 203 ms
20,176 KB
testcase_29 AC 775 ms
41,104 KB
testcase_30 AC 38 ms
10,100 KB
testcase_31 AC 615 ms
34,444 KB
testcase_32 AC 842 ms
41,648 KB
testcase_33 TLE -
testcase_34 TLE -
testcase_35 TLE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/iostream:39,
                 from main.cpp:1:
In member function 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>]',
    inlined from 'int main()' at main.cpp:33:13:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ostream:202:25: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
  202 |       { return _M_insert(__n); }
      |                ~~~~~~~~~^~~~~
main.cpp: In function 'int main()':
main.cpp:17:8: note: 'ans' was declared here
   17 |     ll ans;
      |        ^~~

ソースコード

diff #

#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;
}
0