結果
問題 | No.97 最大の値を求めるくえり |
ユーザー | yuusti |
提出日時 | 2014-12-09 02:19:40 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,201 bytes |
コンパイル時間 | 709 ms |
コンパイル使用メモリ | 90,632 KB |
実行使用メモリ | 4,572 KB |
最終ジャッジ日時 | 2023-09-02 11:57:29 |
合計ジャッジ時間 | 3,607 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 11 ms
4,572 KB |
testcase_02 | AC | 113 ms
4,380 KB |
testcase_03 | AC | 113 ms
4,380 KB |
testcase_04 | AC | 18 ms
4,380 KB |
testcase_05 | AC | 19 ms
4,380 KB |
testcase_06 | AC | 20 ms
4,380 KB |
testcase_07 | AC | 28 ms
4,380 KB |
testcase_08 | AC | 38 ms
4,376 KB |
testcase_09 | AC | 56 ms
4,376 KB |
testcase_10 | AC | 95 ms
4,380 KB |
testcase_11 | AC | 135 ms
4,380 KB |
testcase_12 | AC | 169 ms
4,380 KB |
testcase_13 | AC | 207 ms
4,380 KB |
testcase_14 | AC | 36 ms
4,412 KB |
testcase_15 | AC | 30 ms
4,384 KB |
testcase_16 | AC | 29 ms
4,380 KB |
testcase_17 | AC | 28 ms
4,428 KB |
testcase_18 | WA | - |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <sstream> #include <cstring> #include <cstdio> #include <cstdlib> #include <cmath> #include <queue> #include <stack> #include <map> #include <set> #include <numeric> #include <cctype> #include <tuple> #include <climits> #include <bitset> #include <cassert> #include <random> #include <complex> #ifdef _MSC_VER #include <agents.h> #endif #define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i) #define rep(i, n) FOR(i, 0, n) #define ALL(v) v.begin(), v.end() #define REV(v) v.rbegin(), v.rend() #define MEMSET(v, s) memset(v, s, sizeof(v)) #define UNIQUE(v) (v).erase(unique(ALL(v)), (v).end()) #define MP make_pair #define MT make_tuple using namespace std; typedef long long ll; typedef pair<int, int> P; 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)); } void generateA(int N, vector<int> &A) { for (int i = 0; i < N; ++i) A[i] = xor128() % 100003; } const int mod = 100003; ll mod_pow(ll x, ll n){ ll res = 1; while (n){ if (n & 1) res = res*x%mod; x = x*x%mod; n /= 2; } return res; } ll calcrev(ll x){ return mod_pow(x, mod - 2); } int rev[mod]; int main(){ cin.tie(0); ios::sync_with_stdio(false); int n, q; cin >> n >> q; if (n <= 1000){ vector<int> a(n); generateA(n, a); while (q--){ ll x; cin >> x; ll ans = 0; rep(i, n) ans = max(ans, a[i] * x%mod); cout << ans << '\n'; } } else{ vector<int> b(n); generateA(n, b); vector<int> a(mod); for (auto e : b) a[e] = 1; for (int i = 1; i < mod; ++i) rev[i] = calcrev(i); int cnt = 0; vector<int> ans(mod); rep(i, mod){ for (ll j = mod - 1; j >= 0; --j){ ++cnt; if (a[j*rev[i] % mod]){ ans[i] = j; break; } } } while (q--){ int x; cin >> x; cout << ans[x] << '\n'; } } return 0; }