改题改到了很晚很晚,题解就不写的那么详细了
总之考场上是浑浑噩噩,于是只有暴力分
T1 进制转换
说白了就是一个卡范围枚举......
AC_code
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(i,x,y) for(int i=(x);i<=(y);i++)
#define fu(i,x,y) for(int i=(x);i>=(y);i--)
int read(){
int s=0,t=1;char ch=getchar();
while(!isdigit(ch)){if(ch=='-')t=-1;ch=getchar();}
while(isdigit(ch)){s=s*10+ch-'0';ch=getchar();}
return s*t;
}
const int N=30;
int T,n,m,b;
int sn[N],sm[N];
bool ck(int x){int now=n;
for(sn[0]=1;now;sn[0]++,now/=x){
sn[sn[0]]=now%x;
if(sn[sn[0]]>9)return false;
}sn[0]--;
if(sn[0]<sm[0])return false;
if(sn[0]>sm[0])return true;
fu(i,sn[0],1){
if(sn[i]<sm[i])return false;
else if(sn[i]>sm[i])return true;
}
return true;
}
void work(){
n=read();m=read();int mm=m;
for(sm[0]=1;mm;sm[0]++,mm/=10)sm[sm[0]]=mm%10;sm[0]--;
for(int c=log10(m);c<9;c++)for(int a=1;a<=9;a++){
for(int br=powl(n/a,1.0L/c),bl=max((int)powl((n-(powl(br,c)-1)/(br-1)*9)/a,1.0L/c),(int)10);bl<=br;br--)
if(ck(br)){printf("%lld\n",br);return ;}
}b=101;
while(--b)if(ck(b)){printf("%lld\n",b);return ;}
}
signed main(){
freopen("number.in","r",stdin);
freopen("number.out","w",stdout);
T=read();
while(T--)work();
return 0;
}
T2 遇到困难睡大觉
这个不会
T3 張士超你昨天晚上到底把我家鑰匙放在哪了
发现可以枚举有几个集合超过了限制然后容斥
其实是两个容斥的合并,但是从合并的角度来看并不好理解,直接容斥就好了
AC_code
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(i,x,y) for(int i=(x);i<=(y);i++)
#define fu(i,x,y) for(int i=(x);i>=(y);i--)
int read(){
int s=0,t=1;char ch=getchar();
while(!isdigit(ch)){if(ch=='-')t=-1;ch=getchar();}
while(isdigit(ch)){s=s*10+ch-'0';ch=getchar();}
return s*t;
}
const int N=205;
const int mod=998244353;
int ksm(int x,int y){
int ret=1;
while(y){
if(y&1)ret=ret*x%mod;
x=x*x%mod;y>>=1;
}return ret;
}
int n,m,al,d,a[N],p[N];
int f[N][N][N],ans;
int inv[N],c1[N],c2[N];
signed main(){
freopen("key.in","r",stdin);
freopen("key.out","w",stdout);
m=read();d=read();al=read();n=read();
fo(i,1,m)a[i]=(read()+1)/d,p[i]=read(),inv[i]=ksm(i,mod-2);
f[0][0][0]=1;
fo(i,1,m)fu(j,al/d,0)fu(k,al/d,0)fu(m1,m,0){
if(k*d>al-n||k*d+j*d>al)continue;
// cout<<i<<" "<<j<<" "<<k<<" "<<m1<<" "<<f[j][k][m1]<<endl;
f[j+a[i]][k][m1+1]=(f[j+a[i]][k][m1+1]-f[j][k][m1]*p[i]%mod+mod)%mod;
f[j][k][m1+1]=(f[j][k][m1+1]+f[j][k][m1]*p[i])%mod;
f[j][k+a[i]][m1]=(f[j][k+a[i]][m1]-f[j][k][m1]*(1-p[i]+mod)%mod+mod)%mod;
f[j][k][m1]=f[j][k][m1]*(1-p[i]+mod)%mod;
}
fo(j,0,al/d)fo(k,0,al/d)fo(m1,1,m){
if(k*d>al-n||k*d+j*d>al)continue;
int n1=max(n-j*d,0ll),n2=al-n1-(j+k)*d;
if(!n1){int res=1;
fo(i,1,m-1)res=res*(i+n2)%mod*inv[i]%mod;
ans=(ans+f[j][k][m1]*res)%mod;continue;
}
fo(i,1,m1)c1[i]=c2[i]=0;
c1[1]=1;fo(i,2,m1)c1[i]=c1[i-1]*(n1-1+i-1)%mod*inv[i-1]%mod;
c2[m1]=1;fo(i,n2+1,n2+m-m1)c2[m1]=c2[m1]*i%mod*inv[i-n2]%mod;
fu(i,m1-1,1)c2[i]=c2[i+1]*(n2+m-i)%mod*inv[m-i]%mod;
fo(i,1,m1)ans=(ans+f[j][k][m1]*c1[i]%mod*c2[i])%mod;
}
printf("%lld",ans);
}