求助T4的50分暴力,蒟蒻只有10
查看原帖
求助T4的50分暴力,蒟蒻只有10
750576
I_Will_Not_Give_Code楼主2023/7/1 18:02
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#define ll long long
using namespace std;
const int N=1e5+10,mod=998244353;
typedef pair<int,int> PII;
ll ksm(ll a,ll b)
{
	ll ans=1,base=a,b1=b;
	while(b1>0)
	{
		if(b1&1)
		{
			ans*=base;
			ans%=mod;
		}
		b1>>=1;
		base*=base;
		base%=mod;
	}
	return ans;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll a1=0,b1=0,c,d;
	cin>>a1>>b1;
	while(cin>>c>>d)
	{
		if(!c&&!d) break;
		b1+=d;
	}
	int q;
	cin>>q;
	while(q--)
	{
		ll x;
		cin>>x;
		if(x%a1==0)
		{
			ll s=b1-1;
			while(x>1)
			{
				s--;
				x/=a1;	
			}
			if(s<-1)  cout<<"0 ";
			else if(s==-1) cout<<"1 ";
			else cout<<ksm(2,s)<<' ';
		}
		else cout<<"0 ";
	}
	return 0;
}

到底哪里有问题啊,

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