QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#586554 | #9376. Game | MiniLong | Compile Error | / | / | C++17 | 2.9kb | 2024-09-24 14:02:20 | 2024-09-24 14:02:20 |
Judging History
answer
#include <bits/stdc++.h>
#define _rep(i, x, y) for(int i = x; i <= y; ++i)
#define _req(i, x, y) for(int i = x; i >= y; --i)
#define _rev(i, u) for(int i = head[u]; i; i = e[i].nxt)
#define pb push_back
#define fi first
#define se second
#define mst(f, i) memset(f, i, sizeof f)
using namespace std;
#ifdef ONLINE_JUDGE
#define debug(...) 0
#else
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#endif
typedef long long ll;
typedef pair<int, int> PII;
namespace fastio{
#ifdef ONLINE_JUDGE
char ibuf[1 << 20],*p1 = ibuf, *p2 = ibuf;
#define get() p1 == p2 && (p2 = (p1 = ibuf) + fread(ibuf, 1, 1 << 20, stdin), p1 == p2) ? EOF : *p1++
#else
#define get() getchar()
#endif
template<typename T> inline void read(T &t){
T x = 0, f = 1;
char c = getchar();
while(!isdigit(c)){
if(c == '-') f = -f;
c = getchar();
}
while(isdigit(c)) x = x * 10 + c - '0', c = getchar();
t = x * f;
}
template<typename T, typename ... Args> inline void read(T &t, Args&... args){
read(t);
read(args...);
}
template<typename T> void write(T t){
if(t < 0) putchar('-'), t = -t;
if(t >= 10) write(t / 10);
putchar(t % 10 + '0');
}
template<typename T, typename ... Args> void write(T t, Args... args){
write(t), putchar(' '), write(args...);
}
template<typename T> void writeln(T t){
write(t);
puts("");
}
template<typename T> void writes(T t){
write(t), putchar(' ');
}
#undef get
};
using namespace fastio;
#define multitest() int T; read(T); _rep(tCase, 1, T)
namespace Calculation{
const ll mod = 998244353;
ll ksm(ll p, ll h){ll base = p % mod, res = 1; while(h){if(h & 1ll) res = res * base % mod; base = base * base % mod, h >>= 1ll;} return res;}
void dec(ll &x, ll y){x = ((x - y) % mod + mod) % mod;}
void add(ll &x, ll y){x = (x + y) % mod;}
void mul(ll &x, ll y){x = x * y % mod;}
ll sub(ll x, ll y){return ((x - y) % mod + mod) % mod;}
ll pls(ll x, ll y){return ((x + y) % mod + mod) % mod;}
ll mult(ll x, ll y){return x * y % mod;}
}
using namespace Calculation;
ll a, b, p0, p1, t;
ll solve(ll x, ll y){
if(x <= 0) return 0;
if(y <= 0) return 1;
if(x < y){
ll t = (y - x) / x + ((y - x) % x != 0);
return solve(x, y - t * x) * ksm(p0, t) % mod;
}
if(x == y) return p0;
ll k = (x - y) / y + ((x - y) % y != 0);
return (solve(x - k * y, y) * ksm(p1, k) % mod + (ksm(p1, k) - 1 + mod) % mod * ksm(p1 + mod - 1, mod - 2) % mod * p0 % mod) % mod;
}
int main(){
multitest(){
read(a, b, p0, p1, t);
mul(p0, ksm(t, mod - 2)), mul(p1, ksm(t, mod - 2));
t = ksm(p0 + p1, mod - 2);
mul(p0, t), mul(p1, t);
writeln(solve(a, b) % mod);
}
return 0;
}
详细
answer.code: In function ‘ll solve(ll, ll)’: answer.code:78:39: error: reference to ‘p1’ is ambiguous 78 | return (solve(x - k * y, y) * ksm(p1, k) % mod + (ksm(p1, k) - 1 + mod) % mod * ksm(p1 + mod - 1, mod - 2) % mod * p0 % mod) % mod; | ^~ answer.code:19:25: note: candidates are: ‘char* fastio::p1’ 19 | char ibuf[1 << 20],*p1 = ibuf, *p2 = ibuf; | ^~ answer.code:68:14: note: ‘ll p1’ 68 | ll a, b, p0, p1, t; | ^~ answer.code:78:59: error: reference to ‘p1’ is ambiguous 78 | return (solve(x - k * y, y) * ksm(p1, k) % mod + (ksm(p1, k) - 1 + mod) % mod * ksm(p1 + mod - 1, mod - 2) % mod * p0 % mod) % mod; | ^~ answer.code:19:25: note: candidates are: ‘char* fastio::p1’ 19 | char ibuf[1 << 20],*p1 = ibuf, *p2 = ibuf; | ^~ answer.code:68:14: note: ‘ll p1’ 68 | ll a, b, p0, p1, t; | ^~ answer.code:78:89: error: reference to ‘p1’ is ambiguous 78 | return (solve(x - k * y, y) * ksm(p1, k) % mod + (ksm(p1, k) - 1 + mod) % mod * ksm(p1 + mod - 1, mod - 2) % mod * p0 % mod) % mod; | ^~ answer.code:19:25: note: candidates are: ‘char* fastio::p1’ 19 | char ibuf[1 << 20],*p1 = ibuf, *p2 = ibuf; | ^~ answer.code:68:14: note: ‘ll p1’ 68 | ll a, b, p0, p1, t; | ^~ answer.code: In function ‘int main()’: answer.code:82:24: error: reference to ‘p1’ is ambiguous 82 | read(a, b, p0, p1, t); | ^~ answer.code:19:25: note: candidates are: ‘char* fastio::p1’ 19 | char ibuf[1 << 20],*p1 = ibuf, *p2 = ibuf; | ^~ answer.code:68:14: note: ‘ll p1’ 68 | ll a, b, p0, p1, t; | ^~ answer.code:83:39: error: reference to ‘p1’ is ambiguous 83 | mul(p0, ksm(t, mod - 2)), mul(p1, ksm(t, mod - 2)); | ^~ answer.code:19:25: note: candidates are: ‘char* fastio::p1’ 19 | char ibuf[1 << 20],*p1 = ibuf, *p2 = ibuf; | ^~ answer.code:68:14: note: ‘ll p1’ 68 | ll a, b, p0, p1, t; | ^~ answer.code:84:22: error: reference to ‘p1’ is ambiguous 84 | t = ksm(p0 + p1, mod - 2); | ^~ answer.code:19:25: note: candidates are: ‘char* fastio::p1’ 19 | char ibuf[1 << 20],*p1 = ibuf, *p2 = ibuf; | ^~ answer.code:68:14: note: ‘ll p1’ 68 | ll a, b, p0, p1, t; | ^~ answer.code:85:25: error: reference to ‘p1’ is ambiguous 85 | mul(p0, t), mul(p1, t); | ^~ answer.code:19:25: note: candidates are: ‘char* fastio::p1’ 19 | char ibuf[1 << 20],*p1 = ibuf, *p2 = ibuf; | ^~ answer.code:68:14: note: ‘ll p1’ 68 | ll a, b, p0, p1, t; | ^~