每日作者附:今天拿了150 要是再拿100就好......[捂嘴]不好意思第二人格犯了

下次要努力啊(第二天就拿了第二名耶)

T1多项式输出

题目传送门

总结(自己)

缺了两个判断分别是第一个(原版判断的是头)输出的数不能有+ 和系数为一时不能输出系数

思路

特判巨多(但也没那么多),整数头带个+,负数正常输出,再在每个数后输出x^i即可

附Ac代码

#include<bits/stdc++.h>
using namespace std;
int n,a[110];
bool o;
int main()
{
	freopen("poly.in","r",stdin);
	freopen("poly.out","w",stdout); 
	cin>>n;
	for(int i=n;i>=0;i--){
		cin>>a[i];
	}
	for(int i=n;i>=1;i--){
		if(a[i]==0) continue;
		if(a[i]<0){
			o=1;
			if(a[i]!=-1){
				cout<<a[i];
			}
			else{
				cout<<"-";
			}
			if(i!=1) cout<<"x^"<<i;
			else cout<<"x";
		}
		else if(a[i]>0){
			if(o==1) cout<<"+";
			else o=1;
			if(a[i]!=1){
				cout<<a[i];
			}
			if(i!=1) cout<<"x^"<<i;
			else cout<<"x";
		}
	}
	if(a[0]!=0){
		if(a[0]>0&&o==1) cout<<"+"<<a[0];
		else cout<<a[0]; 
	}
	return 0;
}

T2潜伏者

题目传送门

总结(自己)

hhh笑死我了 模拟写完后看不懂样例三 反复读了n遍题然后发现漏了好多条件 补上就A了hhh

思路

模拟+特判

附Ac代码

#include<bits/stdc++.h>
using namespace std;
string m,a,b;
char t[110],t2[110];
void js()
{
	cout<<"Failed";
	exit(0);
}
int main()
{
	freopen("spy.in","r",stdin);
	freopen("spy.out","w",stdout); 
	cin>>a>>b>>m;
	for(int i=0;i<=26;i++) t2[i]='*',t[i]='*';
	for(int i=0;i<a.size();i++){
		if(a[i]<'A'||a[i]>'Z'||b[i]<'A'||b[i]>'Z'||b[i]<'A'||b[i]>'Z'){
			js();
		}
		if(t[a[i]-'A']!='*'&&t[a[i]-'A']!=b[i]){
			js();
		}
		if(t2[b[i]-'A']!='*'&&t2[b[i]-'A']!=a[i]){
			js();
		}
		t[a[i]-'A']=b[i];
		t2[b[i]-'A']=a[i];
	}
	for(int i=0;i<m.size();i++){
		if(t[m[i]-'A']=='*') js();
	}
	for(int i=0;i<26;i++){
		if(t[i]=='*') js();
	}
	for(int i=0;i<m.size();i++){
		cout<<t[m[i]-'A'];
	}
//	for(int i=0;i<26;i++){
//		cout<<t[i]<<" "<<char(i+'A')<<endl;
//	}
	return 0;
}

T3细胞分裂

题目传送门

总结(自己)

没做 时间肝dp去了

思路

分解质因数 先将给的m1分解质因数(数量要乘*m2)然后对于给定的s 枚举m1的每个质因数 看s能否整除(不能退出)能就看要几个s才能大等m1的这个质因数 最后取最大值个最大 再对每个s的答案取最小即可

附Ac代码

#include<bits/stdc++.h>
using namespace std;
int s[30010],z[30010];
int n,m1,m2,idx,ans=1e9;
void fropn(string a){
	string t1=a+".in",t2=a+".out";
	freopen(t1.c_str(),"r",stdin);
	freopen(t2.c_str(),"w",stdout);
}
void fz(int a,int b)
{
	int t=a;
	for(int i=2;i<=a-1;i++){
		if(t%i!=0) continue;
		int k=0;
		while(t%i==0) 
		{
			k++;
			t/=i;
		}
		s[++idx]=k*b;
		z[idx]=i;
	}
	if(t>1) 
	{
		s[++idx]=b;
		z[idx]=t;
	}
}
int dd(int a)
{
	int res=0;
	for(int i=1;i<=idx;i++){
		
		if(a%z[i]!=0){
			return -1; 
		}
		int k=a,ss=0;
		while(k%z[i]==0) 
		{
			ss++;
			k/=z[i];
		}
		res=max(res,(s[i]+ss-1)/ss);
	}
	return res;
}
int main()
{
	fropn("cell");
	cin>>n;
	cin>>m1>>m2;
	fz(m1,m2);
//	for(int i=1;i<=idx;i++){
//		cout<<z[i]<<" "<<s[i]<<endl;
//	}
	for(int i=1;i<=n;i++){
		int s;
		cin>>s;
		int e=dd(s);		
		if(e==-1) continue;
		ans=min(ans,e);
	}
	if(ans==1e9) cout<<-1; 
	else cout<<ans;
	return 0;
}

T4道路游戏

题目传送门

总结(自己)

用考试时的思路一直没搞出来

思路

dp 3要素

  1. f[i]定义:第i个时间单位时可获得的金币最大数
  2. 初始化:f[i]=-2e9
  3. 递推式:f[i]=max(f[i],f[i-k]+sum-q[w]);(每个地方可以从min(p,i)到i-1的位置过来)

附Ac代码

#include<bits/stdc++.h>
using namespace std;
int n,p,m,q[1010],l[1010][1010],f[1010];
int main()
{
	freopen("game.in","r",stdin);
	freopen("game.out","w",stdout);
	memset(f,-0x3f,sizeof f);
	cin>>n>>m>>p;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>l[i][j];
		}
	}
	f[0]=0;
	for(int i=1;i<=n;i++){
		cin>>q[i]; 
	}
	for(int i=1;i<=m;i++){
		f[i]=-0x3f;
		for(int j=1;j<=n;j++){
			int sum=0;
			for(int k=1;k<=min(p,i);k++){
//				cout<<i<<" "<<j<<" "<<k<<" ";
				int w;
				if(j-k>0) w=j-k;
				else w=n+(j-k)%n;
				sum+=l[w][i-k+1];
//				cout<<w<<" "<<sum<<endl;
				f[i]=max(f[i],f[i-k]+sum-q[w]);
//				cout<<i<<" "<<j<<" "<<k<<" "<<w<<" "<<sum<<" "<<f[i-k]+sum<<endl;
			}
		}
	}
//	for(int i=1;i<=m;i++){
//		cout<<f[i]<<" ";
//	}
	cout<<f[m];
	return 0;
}