求助月赛 T4 50分暴力
  • 板块题目总版
  • 楼主linxuanrui
  • 当前回复11
  • 已保存回复11
  • 发布时间2023/7/1 18:02
  • 上次更新2023/11/3 11:57:46
查看原帖
求助月赛 T4 50分暴力
857323
linxuanrui楼主2023/7/1 18:02
#pragma GCC optmize(2,3,"Ofast","inline")
#include<bits/stdc++.h>
#define endl '\n'
typedef long long ll;
using namespace std;
ll tx,ty,a,b,q,x;
ll qpow(ll a,ll b){
	if(b == -1)return 1;
	if(b < -1)return 0;
	ll ans = 1;
	while(b){
		if(b % 2 == 1)ans = ans * a % 998244353ll;
		a = a * a % 998244353ll,b /= 2;
	}
	return ans;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> a >> b >> tx >> ty;
	cin >> q;
	while(q--){
		cin >> x;
		if(x == 1){
			cout << 0 << " ";
			continue;
		}
		if(qpow(a,(ll)(log(x * 1.0) * 1.0 / log(a * 1.0))) != x)cout << 0 << " ";
		else cout << qpow(2,b - (ll)(log(x * 1.0) * 1.0 / log(a * 1.0)) - 1) << " ";
	}
}

不知道为什么 WA on #11。

2023/7/1 18:02
加载中...