24.10.21 FH

没保存,CaO
抢救了一下,详见
my sol:

A

打表。
1 I
2 II V X
3 III IV VI IX
4 VII
5 VIII
剩余的加X,再加2火柴即可
注意没有40!
完整:
1 I
2 II V X
3 III IV VI IX XI
4 VII XII XV XX
5 VIII XIII XIV XVI XIX XXI
6 XVII XXII XXV XXX
7 XVIII XXIII XXIV XXVI XXIX XXXI
8 XXVII XXXII XXXV
9 XXVIII XXXIII XXXIV XXXVI XXXIX
10 XXXVII
11 XXXVIII

#include<bits/stdc++.h>
using namespace std;
inline int read(){int x=0;char ch=getchar();while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();}return x;}
void put(int x){
	if(x==1){
		printf("1\n");
		printf("I \n");
	}else if(x==2){
		printf("3\n");
		printf("II \n");
		printf("V \n");
		printf("X \n");
	}else if(x==3){
		printf("5\n");
		printf("III \n");
		printf("IV \n");
		printf("VI \n");
		printf("XI \n");
		printf("X \n");
	}else if(x==4){
		printf("4\n");
		printf("VII \n");
		printf("XII \n");
		printf("XV \n");
		printf("XX \n");
	}else if(x==5){
		printf("6\n");
		printf("VIII \n");
		printf("XIII \n");
		printf("XIV \n");
		printf("XVI \n");
		printf("XIX \n");
		printf("XIX \n");
	}else if(x==6){
		printf("4\n");
		printf("XVII \n");
		printf("XXII \n");
		printf("XXV \n");
		printf("XXX\n");
	}else if(x==7){
		printf("6\n");
		printf("XVIII \n");
		printf("XXIII \n");
		printf("XXIV \n");
		printf("XXVI \n");
		printf("XXIX \n");
		printf("XXXI\n");
	}else if(x==8){
		printf("3\n");
		printf("XXVII \n");
		printf("XXXII \n");
		printf("XXXV\n");
	}else if(x==9){
		printf("5\n");
		printf("XXVIII \n");
		printf("XXXIII \n");
		printf("XXXIV \n");
		printf("XXXVI \n");
		printf("XXXIX \n");
	}else if(x==10){
		printf("1\n");
		printf("XXXVII \n");
	}else if(x==11){
		printf("1\n");
		printf("XXXVIII \n");
	}else putchar('0');
}
int main(){
	freopen("match.in","r",stdin);
	freopen("match.out","w",stdout);
	int n=read(); 
	put(n);
}

B

简单前后缀和。
正确性好证:(a^b)^c==a^(b^c)
所以只要找到一个节点使其最大即可。

#include<bits/stdc++.h>
//#define bug putchar('h') 
using namespace std;
inline int read(){int x=0;char ch=getchar();while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();}return x;}
inline int write(int x){if(x>9){write(x/10);}putchar(x%10+'0');}
int a[100010],qian[100010],hou[100010],anss=0x7fffffff,ansb; 
int main(){
	freopen("mistake.in","r",stdin);
	freopen("mistake.out","w",stdout);
	int n=read();
	for(int i=1;i<=n;i++)a[i]=read(),qian[i]=qian[i-1]^a[i];
	for(int i=n;i>0;i--)hou[i]=hou[i+1]^a[i];
	n--;
	for(int i=1;i<n;i++)anss=min(anss,(qian[i]+a[i+1])^hou[i+2]),ansb=max(ansb,(qian[i]+a[i+1])^hou[i+2]);
	write(anss);putchar(' ');write(ansb);
}

C

10pts

暴搜,懒得写

100pts

01背包+。
设总价值为2n,花音必拿h,千圣必拿q
双方的容量分别是 n-x,n-y
然后01背包。

#include<bits/stdc++.h>
//#define bug putchar('h') 
using namespace std;
inline int read(){int x=0;char ch=getchar();while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();}return x;}
inline int write(int x){if(x>9){write(x/10);}putchar(x%10+'0');}
int a[505],b,sum,h,q,dp_h[50005],dp_q[50005],ans;
int main(){
	int n=read();
	for(int i=1;i<=n;i++){
		a[i]=read();
		b=read();
		sum+=a[i];
		if(b==1)h+=a[i],i--,n--;
		if(b==2)q+=a[i],i--,n--;
	}
	h=sum/2-h;q=sum/2-q;
	for(int i=1;i<=n;i++)for(int j=a[i];j<=h;j++)dp_h[j]=max(dp_h[j],dp_h[j-a[i]]+a[i]);
	for(int i=1;i<=n;i++)for(int j=a[i];j<=q;j++)dp_q[j]=max(dp_q[j],dp_q[j-a[i]]+a[i]);
	ans=min(sum-2*(dp_h[h]+sum/2-h),sum-2*(dp_q[q]+sum/2-q));
	write(ans);
}

D

wyy,jbl

Ex:

高精。
不能进位不就是高精异或吗!

#include<bits/stdc++.h>
using namespace std;
char pl(char a,char b){
	int x=(a>='A'?a-'A'+10:a-'0'),y=(b>='A'?b-'A'+10:b-'0'),z=x^y;
	if(z<10)return z+'0';
	else return z+'A'-10;
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s1,s2;
	cin>>s1>>s2;
	while(s1.size()<s2.size())s1="0"+s1;
	while(s1.size()>s2.size())s2="0"+s2;
	int n=s1.size();
	for(int i=0;i<n;i++)s1[i]=pl(s1[i],s2[i]);
	n--;
	int g=0;
	for(;g<n;g++)if(s1[g]!='0')break;
	for(;g<=n;g++)cout<<s1[g];
}
posted @ 2024-10-21 16:22  yzc_is_SadBee  阅读(4)  评论(0编辑  收藏  举报