結果

問題 No.3186 Big Order
コンテスト
ユーザー 蜜蜂
提出日時 2025-05-28 01:02:51
言語 C++23
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
RE  
実行時間 -
コード長 891 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,325 ms
コンパイル使用メモリ 400,968 KB
実行使用メモリ 9,416 KB
最終ジャッジ日時 2026-07-12 04:53:03
合計ジャッジ時間 7,446 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other WA * 1 RE * 34
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;

using bigint = boost::multiprecision::cpp_int;

constexpr int lg = 40;
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(){
  long long 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();
  }
}
0