結果
問題 | No.2122 黄金比で擬似乱数生成 |
ユーザー | 259_Momone |
提出日時 | 2022-11-04 23:26:25 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,121 bytes |
コンパイル時間 | 2,647 ms |
コンパイル使用メモリ | 263,140 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-26 01:52:11 |
合計ジャッジ時間 | 3,834 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 2 ms
4,380 KB |
testcase_03 | AC | 1 ms
4,376 KB |
testcase_04 | AC | 2 ms
4,376 KB |
testcase_05 | AC | 2 ms
4,380 KB |
testcase_06 | AC | 2 ms
4,376 KB |
testcase_07 | AC | 2 ms
4,376 KB |
testcase_08 | AC | 1 ms
4,380 KB |
testcase_09 | AC | 2 ms
4,380 KB |
testcase_10 | AC | 1 ms
4,380 KB |
testcase_11 | AC | 2 ms
4,376 KB |
testcase_12 | AC | 2 ms
4,380 KB |
testcase_13 | AC | 2 ms
4,376 KB |
testcase_14 | AC | 2 ms
4,376 KB |
testcase_15 | AC | 2 ms
4,376 KB |
testcase_16 | AC | 1 ms
4,380 KB |
testcase_17 | AC | 2 ms
4,380 KB |
testcase_18 | AC | 2 ms
4,376 KB |
testcase_19 | AC | 1 ms
4,376 KB |
testcase_20 | AC | 1 ms
4,380 KB |
testcase_21 | AC | 2 ms
4,376 KB |
testcase_22 | AC | 2 ms
4,376 KB |
testcase_23 | AC | 2 ms
4,380 KB |
testcase_24 | AC | 1 ms
4,376 KB |
testcase_25 | AC | 1 ms
4,376 KB |
コンパイルメッセージ
次のファイルから読み込み: /usr/local/gcc7/include/c++/12.2.0/vector:64, 次から読み込み: /usr/local/gcc7/include/c++/12.2.0/functional:62, 次から読み込み: /usr/local/gcc7/include/c++/12.2.0/x86_64-pc-linux-gnu/bits/stdc++.h:71, 次から読み込み: /usr/local/gcc7/include/c++/12.2.0/x86_64-pc-linux-gnu/bits/extc++.h:32, 次から読み込み: main.cpp:1: メンバ関数 ‘std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = std::optional<long unsigned int>; _Alloc = std::allocator<std::optional<long unsigned int> >]’ 内, inlined from ‘int main()’ at main.cpp:30:17: /usr/local/gcc7/include/c++/12.2.0/bits/stl_vector.h:1124:41: 警告: ‘S’ may be used uninitialized [-Wmaybe-uninitialized] 1124 | return *(this->_M_impl._M_start + __n); | ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~ main.cpp: 関数 ‘int main()’ 内: main.cpp:6:19: 備考: ‘S’ はここで定義されています 6 | unsigned long S, M, L; | ^
ソースコード
#include <bits/extc++.h> int main() { using namespace std; constexpr unsigned long mod{10000}; unsigned long S, M, L; { string s; cin >> s; for(const auto c : s)(S *= 10) += c - 48; } cin >> M >> L; const auto m_shuffle{[&M](unsigned long x){ unsigned long a{}, b{1}, c{x}, d{1}, e{}, f{1}; unsigned long n{M}; while(n){ if(n & 1){ tie(d, e, f) = make_tuple(a * d + b * e, b * d + c * e, b * e + c * f); tie(d, e, f) = make_tuple(d % mod, e % mod, f % mod); } tie(a, b, c) = make_tuple(a * a + b * b, b * (a + c), b * b + c * c); tie(a, b, c) = make_tuple(a % mod, b % mod, c % mod); n /= 2; } if(M & 1)(e += 9999) %= mod; return e; }}; vector<optional<unsigned long>> num(10000); for(unsigned long i{}; i < L; ++i){ if(num[S]){ const auto C{i - num[S].value()}; i += (L - i) / C * C; }else num[S] = i; S = m_shuffle(S); } printf("%04lu\n", S); return 0; }