的较小的 次单位根:
| 较小单位根() | 最小单位根 | |||
|---|---|---|---|---|
| 无 | ||||
爆搜程序:
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
typedef long long int li;
typedef pair<ll,ll> pii;
const ll MAXN=2e5+51;
pii res;
mt19937 mt(time(0));
ll r,x,p;
inline ll read()
{
register ll num=0,neg=1;
register char ch=getchar();
while(!isdigit(ch)&&ch!='-')
{
ch=getchar();
}
if(ch=='-')
{
neg=-1;
ch=getchar();
}
while(isdigit(ch))
{
num=(num<<3)+(num<<1)+(ch-'0');
ch=getchar();
}
return num*neg;
}
template <class T>
inline T Min(T x,T y)
{
return x<y?x:y;
}
template <class T>
inline T Max(T x,T y)
{
return x>y?x:y;
}
inline ll rd()
{
return mt()%p;
}
inline ll qpow(ll base,ll exponent)
{
li res=1;
while(exponent)
{
if(exponent&1)
{
res=(li)res*base%p;
}
base=(li)base*base%p,exponent>>=1;
}
return res;
}
inline bool chkx(ll num)
{
return qpow(num,(p-1)>>1)==p-1;
}
inline pii mul(pii x,pii y,ll k)
{
ll x1=x.first,x2=x.second,y1=y.first,y2=y.second;
ll res1=((li)x1*y1%p+(li)x2*y2%p*k%p)%p;
ll res2=((li)x2*y1%p+(li)x1*y2%p)%p;
return make_pair(res1,res2);
}
inline pii Cipolla(ll num)
{
if(chkx(num))
{
return make_pair(-1,-1);
}
ll k,kk,exponent;
while(1)
{
k=rd(),kk=(((li)k*k%p-num)%p+p)%p;
if(chkx(kk))
{
break;
}
}
exponent=(p+1)>>1;
pii res=make_pair(1,0),base=make_pair(k,1);
while(exponent)
{
if(exponent&1)
{
res=mul(res,base,kk);
}
base=mul(base,base,kk),exponent>>=1;
}
return make_pair(Min(res.first,p-res.first),Max(res.first,p-res.first));
}
inline void dfs(ll cur,ll depth)
{
pii pr;
if(depth==x-1)
{
if(cur<100)
{
cout<<cur<<endl;
}
return;
}
pr=Cipolla(cur),dfs(pr.first,depth+1),dfs(pr.second,depth+1);
}
int main()
{
r=read(),x=read(),p=r*(1<<x)+1,cout<<p<<endl,dfs(p-1,0);
}