pyyzDay12
数论
扰动法:
1.提出第0项
2.转化成前一项
3.找到二者之间的关系解方程
组合数
卡特兰数
容斥
背包+超级容斥
#include<iostream>
#include<cstdio>
#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
int x=0,f=1;char ch=getchar();
while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
while (ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}
return x*f;
}
int dp[100005],c[5],d[5];
signed main(){
c[1]=read(),c[2]=read(),c[3]=read(),c[4]=read();
int n=read();
dp[0]=1;
for(int i=1;i<=4;i++){
for(int j=c[i];j<=100000;j++){
dp[j]+=dp[j-c[i]];
}
}
while(n--){
d[1]=read(),d[2]=read(),d[3]=read(),d[4]=read();
d[1]++;
d[2]++;
d[3]++;
d[4]++;
d[1]*=c[1];
d[2]*=c[2];
d[3]*=c[3];
d[4]*=c[4];
int s=read();
int ans=dp[s];
if(s>=d[1]) ans-=dp[s-d[1]];
if(s>=d[2]) ans-=dp[s-d[2]];
if(s>=d[3]) ans-=dp[s-d[3]];
if(s>=d[4]) ans-=dp[s-d[4]];
if(s>=d[1]+d[2]) ans+=dp[s-d[1]-d[2]];
if(s>=d[3]+d[2]) ans+=dp[s-d[3]-d[2]];
if(s>=d[4]+d[2]) ans+=dp[s-d[4]-d[2]];
if(s>=d[1]+d[3]) ans+=dp[s-d[1]-d[3]];
if(s>=d[1]+d[4]) ans+=dp[s-d[1]-d[4]];
if(s>=d[3]+d[4]) ans+=dp[s-d[3]-d[4]];
if(s>=d[1]+d[2]+d[3]) ans-=dp[s-d[1]-d[2]-d[3]];
if(s>=d[1]+d[2]+d[4]) ans-=dp[s-d[1]-d[2]-d[4]];
if(s>=d[4]+d[2]+d[3]) ans-=dp[s-d[4]-d[2]-d[3]];
if(s>=d[1]+d[4]+d[3]) ans-=dp[s-d[1]-d[4]-d[3]];
if(s>=d[1]+d[2]+d[3]+d[4]) ans+=dp[s-d[1]-d[2]-d[3]-d[4]];
cout<<ans<<'\n';
}
return 0;
}
DP+超级容斥
数论
裴蜀定理
循环节定理
威尔逊定理
费马小定理
中国剩余定理
欧拉定理
求任意一个数的欧拉值可以质因数分解
卢卡斯定理

浙公网安备 33010602011771号