結果
| 問題 | No.3462 Buttons |
| コンテスト | |
| ユーザー |
Treewhitetree
|
| 提出日時 | 2026-02-28 16:02:07 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,372 bytes |
| 記録 | |
| コンパイル時間 | 3,653 ms |
| コンパイル使用メモリ | 335,824 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2026-02-28 16:02:38 |
| 合計ジャッジ時間 | 13,940 ms |
|
ジャッジサーバーID (参考情報) |
judge7 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | WA * 10 RE * 5 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<typename T>bool chmax(T &x, T y){if(x>=y)return false;x=y;return true;}
template<typename T>bool chmin(T &x, T y){if(x<=y)return false;x=y;return true;}
const long long mod = 998244353;
long long modpow(long long n, long long r){
long long ans = 1;
while(r){
if(r%2)ans = ans * n % mod;
n = n * n % mod;
r /= 2;
}
return ans;
}
int main(){
int T;
long long A, B, K, a;
cin >> T;
while(T--){
cin >> A >> B >> K;
if(A==0||A<0&&B>=0){
cout << 0 << endl;
}else if(B>1){
a = (A/(B-1)+A)/A;
if(a > K){
cout << K*A%mod << endl;
}else{
cout << a*A%mod*modpow(B%mod, (K-a))%mod << endl;
}
}else if(B>=0){
cout << K*A%mod << endl;
}else if(A>0){
a = (A/(-B-1)+A)/A;
if(a > K){
cout << K*A%mod << endl;
}else if((K-a)%2){
cout << (a+1)*A%mod*modpow(-B%mod, (K-a-1))%mod << endl;
}else{
cout << a*A%mod*modpow(B%mod, (K-a))%mod << endl;
}
}else{
a = (A/(-B-1)+A)/A;
if(a > K){
cout << (K-1)*A%mod*(-B)%mod << endl;
}else if((K-a)%2){
cout << a*A%mod*modpow(B%mod, (K-a))%mod << endl;
}else{
cout << (a+1)*A%mod*modpow(-B%mod, (K-a-1))%mod << endl;
}
}
}
}
Treewhitetree