結果
問題 | No.97 最大の値を求めるくえり |
ユーザー |
|
提出日時 | 2022-06-02 02:52:18 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,108 bytes |
コンパイル時間 | 842 ms |
コンパイル使用メモリ | 90,352 KB |
最終ジャッジ日時 | 2024-11-15 02:18:13 |
合計ジャッジ時間 | 2,323 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:14:5: error: 'cin' was not declared in this scope 14 | cin >> N >> Q; | ^~~ main.cpp:2:1: note: 'std::cin' is defined in header '<iostream>'; did you forget to '#include <iostream>'? 1 | #include<atcoder/all> +++ |+#include <iostream> 2 | using namespace std; main.cpp:25:13: error: 'cout' was not declared in this scope 25 | cout << 0 << '\n'; | ^~~~ main.cpp:25:13: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'? main.cpp:42:9: error: 'cout' was not declared in this scope 42 | cout << ans << '\n'; | ^~~~ main.cpp:42:9: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
ソースコード
#include<atcoder/all>using namespace std;using ll = long long;unsigned xor128_x = 123456789, xor128_y = 362436069, xor128_z = 521288629, xor128_w = 88675123;unsigned xor128() {unsigned t = xor128_x ^ (xor128_x << 11);xor128_x = xor128_y; xor128_y = xor128_z; xor128_z = xor128_w;return xor128_w = xor128_w ^ (xor128_w >> 19) ^ (t ^ (t >> 8));}int main(){int N, Q;cin >> N >> Q;vector<int> A(N);vector<bool> t(100003);for(int i = 0; i < N; i++){A[i] = xor128() % 100003;t[A[i]] = true;}ll q;while(Q--){cin >> q;if(q == 0){cout << 0 << '\n';continue;}ll ans = 0;if(N <= 500){for(int i = 0; i < N; i++){ans = max(ans, q * A[i] % 100003);}}else{ll inv = atcoder::inv_mod(q, 100003);for(int i = 100002; i >= 0; i--){if(t[i * inv % 100003]){ans = i;break;}}}cout << ans << '\n';}}