QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#152603#6704. Happy EquationSceneTL 5ms3576kbC++141.7kb2023-08-28 14:15:202023-08-28 14:15:21

Judging History

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

  • [2023-08-28 14:15:21]
  • 评测
  • 测评结果:TL
  • 用时:5ms
  • 内存:3576kb
  • [2023-08-28 14:15:20]
  • 提交

answer

#include<bits/stdc++.h>
#define fo(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
#define Ts template<typename Ty,typename... Ar>
#define Tp template<typename Ty>
#define ll long long
#define RS register
#define gc getchar
#define pc putchar
#define I inline
using namespace std;
Tp I Ty wmax(Ty a,Ty b){return a>=b? a:b;}
Tp I Ty wmin(Ty a,Ty b){return a<=b? a:b;}
namespace WrongIO
{
	Tp I void read(Ty &x){x=0;Ty opt=1;char c=gc();while(!isdigit(c)&&c!='-')c=gc();if(c=='-')opt=-1,c=gc();while(isdigit(c))x=(x<<3)+(x<<1),x+=c-'0',c=gc();x*=opt;return;}
	Tp I void write(Ty x){short OI_USE[50],OI_top=0;if(x<=0) if(x==0)pc('0');else pc('-'),x*=-1;while(x)OI_USE[++OI_top]=x%10,x/=10;while(OI_top--)pc(OI_USE[OI_top+1]+'0');return;}
    I void writec(char c[]){int len=strlen(c);for(int i=0;i<len;i++)pc(c[i]);}
    I void writes(string s){int len=s.length();for(int i=0;i<len;i++)pc(s[i]);}
    I void readc(char &c,int l,int r){c=gc(); while(c!=EOF&&(c<l||c>r)) c=gc();}
    I void readc(char &c,char val){c=gc();while(c!=EOF&&c!=val) c=gc();}
    I void readc(char val){char c;c=gc();while(c!=EOF&&c!=val) c=gc();}
    I void readls(string &s){char c=gc();while(c!='\n') s.push_back(c),c=gc();}
    Ts I void read(Ty &x,Ar &...y) {read(x),read(y...);}
} using namespace WrongIO;
ll T,a,p;
ll qpow(ll base,ll num)
{
	ll az=1;
	while(num>1)
	{
		if(num&1) az=az*base%p;
		base=base*base%p; num/=2;
	}
	return az*base%p;
}
int main()
{
	read(T);
	while(T--)
	{
		ll nn=0; read(a,p); p=1<<p;
		for(int i=1;i<=p;i++)
		if(qpow(a,i)==qpow(i,a)) nn++;
		//write(i),pc(' '),nn++;
		//writes("aaaaaaaaa "),
		write(nn),pc('\n');
//		read(a,p);
//		if(a%2==0) write((1<<p-1)-1),pc('\n');
//		else write(1),pc('\n');
	}
}

详细

Test #1:

score: 100
Accepted
time: 5ms
memory: 3576kb

input:

2
6 12
8 16

output:

1023
16383

result:

ok 2 number(s): "1023 16383"

Test #2:

score: -100
Time Limit Exceeded

input:

1000
959668315 17
173599849 18
452866086 16
984874375 15
346061855 21
440851881 22
224960642 16
176079916 16
656766412 21
283466925 25
20353211 27
691728649 20
772055116 17
459468637 21
206618043 15
987058694 25
621275781 22
787193761 15
812760680 25
993799948 25
126264161 18
897813346 16
762713004 ...

output:


result: