QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#199219#6887. Data GenerationhazeAC ✓86ms3656kbC++231.1kb2023-10-03 23:10:282023-10-03 23:10:28

Judging History

你现在查看的是最新测评结果

  • [2023-10-03 23:10:28]
  • 评测
  • 测评结果:AC
  • 用时:86ms
  • 内存:3656kb
  • [2023-10-03 23:10:28]
  • 提交

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