跳到正文

I_AM_STANBO

654150

不要jc我!!!!!!!

在洛谷打开
资料、奖项与版本

资料

编号
654150
抓取

陶片放逐

无权限变更

查看记录

版本

  1. v2当前
  2. v1

https://oi-wiki.org/math/combinatorics/polya/

CRT:

M =∏mi,Mi = M/mi,ti 是 Mi 在模 mi 群下的逆元。

x ≡∑1~n ai *ti *Mi (mod M)

超级快读::

C++
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define in inline
namespace fast_io
{
	char buf[1<<12],*p1=buf,*p2=buf,sr[1<<23],z[23],nc;int C=-1,Z=0,Bi=0,ny;
	in char gc() {return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++;}
	in ll read()
	{
		ll x=0;ny=1;while(nc=gc(),(nc<48||nc>57)&&nc!=EOF)if(nc==45)ny=-1;Bi=1;if(nc<0)return nc;
		x=nc-48;while(nc=gc(),47<nc&&nc<58&&nc!=EOF)x=(x<<3)+(x<<1)+(nc^48),Bi++;return x*ny;
	}
	in db gf() {int a=read(),y=ny,b=(nc!='.')?0:read();return (b?a+(db)b/pow(10,Bi)*y:a);}
	in int gs(char *s) {char c,*t=s;while(c=gc(),c<=32);*s++=c;while(c=gc(),c>32)*s++=c;return s-t;}
	in void ot() {fwrite(sr,1,C+1,stdout);C=-1;}
	in void flush() {if(C>1<<22) ot();}
	template <typename T>
	in void write(T x,char t)
	{
		int y=0;if(x<0)y=1,x=-x;while(z[++Z]=x%10+48,x/=10);
		if(y)z[++Z]='-';while(sr[++C]=z[Z],--Z);sr[++C]=t;flush();
	}
	in void write(char *s) {int l=strlen(s);for(int i=0;i<l;i++)sr[++C]=*s++;sr[++C]='\n';flush();}
};

exgcd:

C++
void exgcd(int a, int b, int &x, int &y){
	if (a % b == 0) { 
		x = 0; y = 1; 
	} 
	else { 
		exgcd(b, a % b, y, x);
		y ‐= a / b * x; 
	}
}

同余:

C++
void exgcd(int a, int b, int &x, int &y){
	if (a % b == 0) { 
		x = 0; y = 1; 
	} 
	else { 
		exgcd(b, a % b, y, x);
		y ‐= a / b * x; 
	}
}
int main(){
  // a*a^(-1)%p=1
  exgcd(a,b,x,y) // a*a^{-1} + pk = 1
  cout<<(x%p+p);
}

组合数:

C++
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define in inline
namespace fast_io
{
	char buf[1<<12],*p1=buf,*p2=buf,sr[1<<23],z[23],nc;int C=-1,Z=0,Bi=0,ny;
	in char gc() {return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++;}
	in ll read()
	{
		ll x=0;ny=1;while(nc=gc(),(nc<48||nc>57)&&nc!=EOF)if(nc==45)ny=-1;Bi=1;if(nc<0)return nc;
		x=nc-48;while(nc=gc(),47<nc&&nc<58&&nc!=EOF)x=(x<<3)+(x<<1)+(nc^48),Bi++;return x*ny;
	}
	in db gf() {int a=read(),y=ny,b=(nc!='.')?0:read();return (b?a+(db)b/pow(10,Bi)*y:a);}
	in int gs(char *s) {char c,*t=s;while(c=gc(),c<=32);*s++=c;while(c=gc(),c>32)*s++=c;return s-t;}
	in void ot() {fwrite(sr,1,C+1,stdout);C=-1;}
	in void flush() {if(C>1<<22) ot();}
	template <typename T>
	in void write(T x,char t)
	{
		int y=0;if(x<0)y=1,x=-x;while(z[++Z]=x%10+48,x/=10);
		if(y)z[++Z]='-';while(sr[++C]=z[Z],--Z);sr[++C]=t;flush();
	}
	in void write(char *s) {int l=strlen(s);for(int i=0;i<l;i++)sr[++C]=*s++;sr[++C]='\n';flush();}
};
using namespace fast_io;
const int N=5e6+5,p=998244353;
int a,b,fac[N],inv[N];
int c(int n,int m)
{
	return n<m?0:1ll*fac[n]*inv[m]%p*inv[n-m]%p;
}
int main()
{
	fac[0]=fac[1]=inv[0]=inv[1]=1;
	for(int i=2;i<N;i++) fac[i]=1ll*fac[i-1]*i%p,inv[i]=1ll*(p-p/i)*inv[p%i]%p;
	for(int i=2;i<N;i++) inv[i]=1ll*inv[i-1]*inv[i]%p;
	// 1
	/*
	inv[n]=	qpow(fac[n],p-2);
	for(int i=n-1;i;i--) inv[i]=1ll*inv[i+1]*(i+1)%p;
	*/
	int T=read(),ans=0;read();
	while(T--)
	{
		int x=read(),y=read();
		ans^=c(x,y);
	}
	cout<<ans;
}

https://www.bilibili.com/video/BV1SW411y7W1/?spm_id_from=333.788.recommend_more_video.0&vd_source=3ef0dc0d18b1b7b2cd5bc1c82b244210

共 1 篇
  1. 休闲·娱乐

    11月11日等第已出,我已经拿到证书

    该文本为虚构内容,作者以幽默口吻分享了“光棍节”获得竞赛成绩的喜悦,自称已通过CSP-S(中国计算机学会能力认证-提高组)第一轮考试并取得证书,用“AK”(全对)和“穿越”等网络用语调侃自己的表现,并附上成绩与证书图片链接。