QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#199219 | #6887. Data Generation | haze | AC ✓ | 86ms | 3656kb | C++23 | 1.1kb | 2023-10-03 23:10:28 | 2023-10-03 23:10:28 |
Judging History
answer
#include<bits/stdc++.h>
#define irep(i,l,r) for(int i = l; i <= r; ++i)
#define drep(i,r,l) for(int i = r; i >= l; --i)
#define ceil(pp,qq) (((pp)>0)^((qq)>0)?-Abs(pp)/Abs(qq):(pp)%(qq)?(pp)/(qq)+1:(pp)/(qq))
#define floor(pp,qq) (((pp)>0)^((qq)>0)?-ceil(abs(pp),abs(qq)):(pp)/(qq))
#define ll __int128
using namespace std;
ll Abs(ll x){return x > 0 ? x : - x;}
inline ll read(){
char ch = getchar();
ll s = 0; bool w = 0;
while(!isdigit(ch)){if(ch == '-')w = 1;ch = getchar();}
while(isdigit(ch))s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar();
return w ? - s : s;
}
const int itinf = 2e9;
const ll llinf = 4e18;
const ll mod = 998244353;
const int N = 500009;
ll qpow(ll base, ll b){
ll ans = 1;
base %= mod;
while(b){
if(b & 1)ans *= base, ans %= mod;
base = (base * base) % mod, b >>= 1;
}
return ans;
}
int main(){
ll T = read();
while(T --){
__int128 n = read() , m = read() ;
printf("%lld\n",(long long)((n - (1 + (n - 1) * qpow
((1 - 2 * qpow(n, mod - 2) % mod) + mod, m)
) % mod + mod) % mod));
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 86ms
memory: 3656kb
input:
100000 19491001 19491001 999999999449325353 939501148 400027352 999999998707619026 999999998353720210 999999999303057191 1879045722 1874448608 999999998385974740 1710466660 109045962 999999998020190078 999999998217418921 999999998898659805 999999999999986692 999999998389218199 351693073 2130408866 1...
output:
79256423 60176292 660407710 893892599 601021657 353145264 33871948 852325473 308290667 313185571 805837881 700368815 711096361 895992243 830757079 419158396 754661682 184055154 728055491 1 323104191 72240859 553717086 361196534 971355231 232530344 149284730 833553979 48731930 0 296123988 928795526 5...
result:
ok 100000 lines