結果
問題 |
No.3186 Big Order
|
ユーザー |
![]() |
提出日時 | 2025-05-28 14:34:33 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 568 ms / 2,000 ms |
コード長 | 889 bytes |
コンパイル時間 | 6,741 ms |
コンパイル使用メモリ | 363,072 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-06-21 02:42:31 |
合計ジャッジ時間 | 14,925 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 35 |
ソースコード
#include <iostream> #include <vector> #include <boost/multiprecision/cpp_int.hpp> using namespace std; using bigint = boost::multiprecision::cpp_int; constexpr int lg = 135; constexpr long long mod = 998244353; bool is_big(long long a, long long b, long long c, long long d){ if(a * d > b * c){ return true; } return false; } void solve(){ bigint a, b, c; cin >> a >> b >> c; vector<long long> v(lg, 0); bigint state = 1; for(int i = 0; i < lg; i++){ if(i > 0){ v[i] = v[i - 1]; } while(state % c == 0){ state /= c; v[i]++; } state *= a; } if(v[lg - 1] == 0){ cout << 0 << "\n"; return; } int arg = 1; for(int i = 2; i < lg; i++){ if(is_big(v[i], i, v[arg], arg)){ arg = i; } } cout << ((v[arg] * b) / arg) % mod << "\n"; } int main(){ int t; cin >> t; while(t--){ solve(); } }