竞赛笔记竞赛C++2024-03-30竞赛笔记&周赛总结笔记
Minecraft-Sep2024/3/30
先放个图搞笑一下awa

又双叒叕放2个好东西……
JIYU万能密码
我的LGLG.TOP
正片
T1药剂实验
(这题暴力也可以啊哈哈哈)


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
   |  #include<iostream>   using namespace std;   int main()   {       int a,b,c,d,e,f,g,h,i,j,in,x=0;       cin>>in;       for (a=1;a<=3;a++)       {           for (b=1;b<=3;b++)           {               for (c=1;c<=3;c++)               {                   for (d=1;d<=3;d++)                   {                       for (e=1;e<=3;e++)                       {                           for (f=1;f<=3;f++)                           {                               for (g=1;g<=3;g++)                               {                                   for(h=1;h<=3;h++)                                   {                                       for (i=1;i<=3;i++)                                       {                                           for (j=1;j<=3;j++)                                           {                                               if (a+b+c+d+e+f+g+h+i+j==in)                                               {                                                   x++;                                               }                                           }                                       }                                   }                               }                           }                       }                   }               }           }       }       cout<<x<<endl;       for (a=1;a<=3;a++)       {           for (b=1;b<=3;b++)           {               for (c=1;c<=3;c++)               {                   for (d=1;d<=3;d++)                   {                       for (e=1;e<=3;e++)                       {                           for (f=1;f<=3;f++)                           {                               for (g=1;g<=3;g++)                               {                                   for(h=1;h<=3;h++)                                   {                                       for (i=1;i<=3;i++)                                       {                                           for (j=1;j<=3;j++)                                           {                                               if (a+b+c+d+e+f+g+h+i+j==in)                                               {                                                   cout<<a<<" ";                                                   cout<<b<<" ";                                                   cout<<c<<" ";                                                   cout<<d<<" ";                                                   cout<<e<<" ";                                                   cout<<f<<" ";                                                   cout<<g<<" ";                                                   cout<<h<<" ";                                                   cout<<i<<" ";                                                   cout<<j<<endl;                                               }                                           }                                       }                                   }                               }                           }                       }                   }               }           }       }   } 
 
  | 
 
T2装饰
完全没有想到是完全背包
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
   | #include<bits/stdc++.h> using namespace std; int n,m; int a[10001]; int f[114][514]; const int mod=1e6+7; int main(){ 	cin>>n>>m; 	for(int i=1;i<=n;i++) cin>>a[i]; 	f[0][0]=1; 	for(int i=1;i<=n;i++){ 		for(int j=0;j<=m;j++){ 			for(int k=0;k<=j&&k<=a[i];k++){ 				f[i][j]=(f[i][j]+f[i-1][j-k])%mod; 			} 		} 	} 	cout<<f[n][m]; }
   | 
 
T3星航补给
又双叒叕是一个DFS
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
   | #include<bits/stdc++.h> using namespace std; int n,m,a[100001],l,r,ans; void dfs(int x,int w){ 	if(x>n){ 		if(w>=l){ 			ans++; 		} 		return; 	} 	if(w+a[x]<=r){ 		dfs(x+1,w+a[x]); 	} 	dfs(x+1,w); } int main(){ 	cin>>n>>l>>r; 	for(int i=1;i<=n;i++) cin>>a[i]; 	dfs(1,0); 	cout<<ans; 	return 0; }
   | 
 
T4乐队采购
nnd这题这么简单就AC了!降黄!降黄!降黄!降黄!降黄!降黄!降黄!

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
   | #include<bits/stdc++.h> using namespace std; int n,m,s,ans; struct node{ 	int w,v; }b[114514]; bool cmp(node x,node y){ 	if(x.v==y.v){ 		return x.w<y.w; 	} 	else return x.v>y.v; } int main(){ 	cin>>n>>m; 	s=m; 	for(int i=1;i<=n;i++) cin>>b[i].w>>b[i].v; 	sort(b+1,b+1+n,cmp); 	int x=1; 	for(int i=1;i<=n;i++){ 		if(m-b[i].w>=0){ 			if(abs(b[i].w-b[x].w)<=3)  			if(b[i].w>b[x].w) x=i; 			m-=b[i].w; 			ans+=b[i].v;  		} 	}  	cout<<ans; }
   | 
 
总结:
没有发挥好(怎么都t*用DFS做啊,我正好不太会),继续努力!