# Luogu P5285 [十二省联考2019]骗分过样例

### Preface

ZJOI一轮被麻将劝退的老年选手看到这题就两眼放光，省选也有乱搞题

### Case1~Case3

Case3我们通过欧拉定理$x^p=x^{p\mod\phi(p)}$，当$\text{p is a prime number}$时，有$x^p=x^{p\mod p-1}$

### Case4

$998244353$变成了?，我们发现这时候模数要自己猜

### Case5

264708066 1996649514996338529
264708068 1589589654696467295

#include<cstdio>
#include<cctype>
#include<algorithm>
using namespace std;
const int N=10005;
struct data
{
int x; long long y;
friend inline bool operator < (const data& A,const data& B)
{
return A.x<B.x;
}
}a[N]; int n,mi=1e9,pos;
int main()
{
freopen("mindlt.txt","w",stdout);
FILE *fin1=fopen("software.in","r"),*fin2=fopen("software5.ans","r");
register int i; char str[20]; fscanf(fin1,"%s",str+1);
for (fscanf(fin1,"%d",&n),i=1;i<=n;++i) fscanf(fin1,"%d",&a[i].x);
for (i=1;i<=n;++i) fscanf(fin2,"%lld",&a[i].y);
for (sort(a+1,a+n+1),i=2;i<=n;++i) if (a[i].y<a[i-1].y)
{
if (a[i].x-a[i-1].x<mi) mi=a[i].x-a[i-1].x,pos=i;
}
return printf("%d %lld\n%d %lld",a[pos-1].x,a[pos-1].y,a[pos].x,a[pos].y),0;
}
for i in range(100,201):
if 719200885258981741674%i==0:
if 719200885258981741674//i>5211500658258874318:
print(719200885258981741674//i,end=' ')


### Case6~Case7

#include<cstdio>
#include<map>
#define RI register int
using namespace std;
const int N=10000005,mod=998244353;
int lst,nw; map <int,int> pos;
int main()
{
freopen("circle.txt","w",stdout);
pos[lst=1]=0; for (RI i=1;;++i)
{
nw=19*lst%mod; if (pos.count(nw))
return printf("%d %d",pos[nw]-1,i-pos[nw]),0;
pos[nw]=i; lst=nw;
}
return 0;
}

### Case8~Case10

woc终于写完第一个部分了，然后发现这第二个点的输出怎么都那么大呢

### Case11~Case13

• 剩下的因数为素数，直接MR判一发即可
• 剩下一个平方数，直接sqrt后回代判断，并且直接把$\mu$置为$0$
• 这个数是两个不同的大于$10^6$的素数的乘积（容易发现不可能是三个及以上的积），这个什么都不干即可（乘两个$-1$等于不变）

### Case14~Case16

#include<cstdio>
#include<cctype>
#define RI register int
#define CI const int&
using namespace std;
const int MR_prime[3]={2,3,61},ST=233333333,MID=1500000000;
const bool tar[50]={0,0,0,1,1,1,0,0,1,1,0,1,0,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,0,0,0,0,1,1,0,0,1,0,0,0,0,0,0,1,1,0,0,1,1,0};
inline int quick_pow(int x,int p,int mod,int mul=1)
{
for (;p;p>>=1,x=1LL*x*x%mod) if (p&1) mul=1LL*mul*x%mod; return mul;
}
inline bool Singer_MR(CI x,CI p)
{
if (quick_pow(x,p-1,p)!=1) return 0;
int t=p-1; while (!(t&1))
{
t>>=1LL; int val=quick_pow(x,t,p);
if (val!=1&&val!=p-1) return 0;
if (val==p-1) return 1;
}
return 1;
}
inline bool Miller_Rabin(CI x)
{
RI i; for (i=0;i<3;++i) { if (x==MR_prime[i]) return 1; if (x%MR_prime[i]==0) return 0; }
for (i=0;i<3;++i) if (!Singer_MR(MR_prime[i],x)) return 0; return 1;
}
inline bool check(CI mod)
{
for (RI i=0;i<50;++i) if (quick_pow(ST+i,mod-1>>1,mod)==1&&tar[i]) return 0; return 1;
}
int main()
{
freopen("gr_mod.txt","w",stdout);
for (RI i=0;;++i)
{
if (Miller_Rabin(MID-i)&&check(MID-i)) { printf("%d %d",MID-i,i); break; }
if (Miller_Rabin(MID+i)&&check(MID+i)) { printf("%d %d",MID+i,i); break; }
}
return 0;
}

### ALL CODE

#include<cstdio>
#include<cctype>
#include<cmath>
#include<cstring>
#define RI register int
#define RL register LL
#define CI const int&
#define CL const LL&
#define Tp template <typename T>
using namespace std;
typedef long long LL;
class FastInputOutput
{
public:
int pt[25];
{
x=0; char ch; while (!isdigit(ch=getchar()));
while (x=(x<<3)+(x<<1)+(ch&15),isdigit(ch=getchar()));
}
Tp inline void read(T& x,const T& mod)
{
x=0; char ch; while (!isdigit(ch=getchar()));
while (x=(10ull*x+(ch&15))%mod,isdigit(ch=getchar()));
}
Tp inline void write(T x)
{
if (!x) return (void)(putchar('0'),putchar('\n'));
if (x<0) putchar('-'),x=-x;
RI ptop=0; while (x) pt[++ptop]=x%10,x/=10;
while (ptop) putchar(pt[ptop--]+48); putchar('\n');
}
}F;
namespace Case1 //19^x%mod
{
static const int L=101000,st=55244,len=45699;
int n,val[L+5]; LL x,mod;
inline void inc(LL& x,CL y)
{
unsigned long long t=x+y; x=t>=mod?t-mod:t;
}
inline LL quick_mul(LL x,LL y,LL sum=0)
{
for (;y;inc(x,x),y>>=1) if (y&1) inc(sum,x); return sum;
}
inline LL quick_pow(LL p,LL x=19,LL mul=1)
{
for (;p;p>>=1,x=quick_mul(x,x))
if (p&1) mul=quick_mul(mul,x); return mul;
}
inline void work(void)
{
}
inline void wa_work(void)
{
val[0]=1; for (RI i=1;i<=L;++i) val[i]=19*val[i-1]%mod;
}
/*inline int str_mod(const char *str,CI mod,int ret=0)
{
int len=strlen(str); for (RI i=0;i<len;++i)
ret=((ret<<3)+(ret<<1)+(str[i]&15))%mod; return ret;
}*/
inline void solve(void)
{
char opt=getchar(); if (opt=='_') return F.read(n),mod=998244353,work();
/*for (RI i=1145099;;++i) if (Miller_Rabin(i))
{
if (mod=i,quick_pow(str_mod("627811703016764290815178977207148434322",mod-1))==642666)
return;
}*/
opt=getchar(); if (opt=='+') mod=5211600617818708273LL; else mod=1145141; work();
}
};
namespace Case2 //number identify
{
const int MR_prime[3]={2,3},N=1e6,MX=13123111;
int n,prime[N+5],id[MX+5],mpr[N+5],mu[N+5],cnt,tot,mod;
LL l,r,mul[N+5],t; bool vis[MX+5];
inline LL quick_mul(CL x,CL y,CL mod)
{
LL k=(LL)((1.0L*x*y)/(1.0L*mod)),r=x*y-k*mod;
r-=mod; while(r<0LL) r+=mod; return r;
}
inline LL quick_pow(LL x,LL p,LL mod,LL mul=1)
{
for (;p;p>>=1,x=quick_mul(x,x,mod))
if (p&1) mul=quick_mul(mul,x,mod); return mul;
}
inline bool Singer_MR(CI x,CL p)
{
if (quick_pow(x,p-1,p)!=1) return 0;
LL t=p-1; while (!(t&1))
{
t>>=1LL; LL val=quick_pow(x,t,p);
if (val!=1&&val!=p-1) return 0;
if (val==p-1) return 1;
}
return 1;
}
inline bool Miller_Rabin(CL x)
{
RI i; for (i=0;i<2;++i) { if (x==MR_prime[i]) return 1; if (x%MR_prime[i]==0) return 0; }
for (i=0;i<2;++i) if (!Singer_MR(MR_prime[i],x)) return 0; return 1;
}
inline void prime_solve(void)
{
{
putchar(Miller_Rabin(i)?'p':'.'); putchar('\n');
}
}
#define Pi prime[j]
inline void init(CI n)
{
vis[1]=mu[1]=1; for (RI i=2;i<=n;++i)
{
if (!vis[i]) prime[++cnt]=i,mu[i]=-1;
for (RI j=1;j<=cnt&&i*Pi<=n;++j)
{
vis[i*Pi]=1; if (i%Pi) mu[i*Pi]=-mu[i]; else break;
}
}
}
inline void mu_solve(void)
{
{
{
for (i=l;i<=r;++i) putchar(mu[i]?(~mu[i]?'+':'-'):'0');
putchar('\n'); continue;
}
for (i=1;i<=len;++i) mu[i]=mul[i]=1; for (j=1;j<=cnt;++j)
for (RL i=1LL*((l-1)/Pi+1)*Pi;i<=r;i+=Pi)
if (i%(1LL*Pi*Pi)==0) mu[i-l+1]=0; else mu[i-l+1]*=-1,mul[i-l+1]*=Pi;
for (i=1;i<=len;++i)
{
if (!mu[i]) { putchar('0'); continue; }
if (mul[i]!=i+l-1)
{
if (Miller_Rabin(t=(i+l-1)/mul[i])) mu[i]*=-1; else
{
LL sq=(LL)sqrt(t); if (sq*sq==t) mu[i]=0;
}
}
if (!mu[i]) putchar('0'); else putchar(~mu[i]?'+':'-');
} putchar('\n');
}
}
inline void resolve(int x)
{
tot=0; for (RI j=1;Pi*Pi<=x;++j) if (x%Pi==0)
{
mpr[++tot]=Pi; while (x%Pi==0) x/=Pi;
}
if (x>1) mpr[++tot]=x;
}
#undef Pi
inline bool is_GR(CI x)
{
for (RI i=1;i<=tot;++i)
if (quick_pow(x,(mod-1)/mpr[i],mod)==1) return 0; return 1;
}
inline void GR_Sieve(CI mod)
{
RI i,j; memset(vis,0,sizeof(vis)); int gr,pfx;
for (i=1;i<mod;++i) if (is_GR(i)) { gr=i; break; }
for (i=1,pfx=gr;i<mod;++i,pfx=1LL*pfx*gr%mod) id[pfx]=i;
for (i=1;i<=tot;++i) for (j=mpr[i];j<mod;j+=mpr[i]) vis[j]=1;
for (i=1;i<mod;++i) putchar(vis[id[i]]?'.':'g');
}
inline void GR_solve(void)
{
{
if (mod==998244353||mod==1515343657)
{
resolve(mod-1); for (RI i=l;i<=r;++i)
putchar(is_GR(i)?'g':'.');
} else resolve(mod-1),GR_Sieve(mod); putchar('\n');
}
}
inline void solve(void)
{
char opt=getchar(); switch (opt)
{
case 'p':
prime_solve(); break;
case 'u':
mu_solve(); break;
case 'g':
GR_solve(); break;
}
}
};
int main()
{
//freopen("software.in","r",stdin); freopen("software.out","w",stdout);
char opt=getchar(); if (opt=='1') Case1::solve(); else Case2::solve();
return 0;
}

### Postscript

posted @ 2019-04-14 20:46 hl666 阅读(...) 评论(...) 编辑 收藏