QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#803834 | #8962. Immensely Long Expressions | panhuachao# | WA | 0ms | 3816kb | C++20 | 936b | 2024-12-07 18:57:36 | 2024-12-07 18:57:43 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll p = 998244353;
ll quickpow(ll base, ll index){
base %= p;
index %= p-1;
ll res = 1;
while(index > 0){
if(index & 1) res = res * base % p;
base = base * base % p; index >>= 1;
}
return res;
}
ll inv(ll v){ v = (v%p+p)%p; return quickpow(v, p-2); }
const ll inv2 = inv(2);
const ll q = inv(19) * ((0+1+2+3+4+5+6+7+8+9+inv(1)+inv(2)+inv(3)+inv(4)+inv(5)+inv(6)+inv(7)+inv(8)+inv(9))%p) % p;
const ll g0 = inv(10) * (0+1+2+3+4+5+6+7+8+9) % p;
ll n;
void solve(){
scanf("%lld", &n);
ll k = n/2;
ll ans = g0 * (inv2 * (1-quickpow(inv2*q,k)) % p * inv(1-inv2*q) % p + quickpow(inv2*q, k)) % p;
printf("%lld\n", (ans%p+p)%p);
}
int main(){
// printf("%lld\n", (inv2 * g0 % p + inv2 * g0 % p * q % p) % p);
int t; scanf("%d", &t);
while(t--) solve();
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3816kb
input:
7 1 3 5 7 9 998244353 111111111224317155
output:
499122181 390619403 593408828 798770225 581676430 418437218 455967110
result:
wrong answer 2nd numbers differ - expected: '137441435', found: '390619403'