第十一届山东省大学生程序设计竞赛
题号 | 题目 | 知识点 | 难度 |
---|---|---|---|
A | Beta Go | ||
B | Build Roads | 最小生成树,思维题 | 一般 |
C | Cat Virus | 构造题 | 有点难想 |
D | Dyson Box | 模拟 | 签到题 |
E | Evaluate Expression | ||
F | Birthday Cake | ||
G | Grade Point Average | 模拟 | 签到题 |
H | Adventurer’s Guild | 背包问题 | 签到题 |
I | Chemical Code | ||
J | Tuition Agent | ||
K | Piggy Calculator | ||
L | Construction of 5G Base Stations | ||
M | Matrix Problem | 签到题 |
文章目录
- D Dyson Box
- G Grade Point Average
- H Adventurer’s Guild
D Dyson Box
题意:
二维空间里放了n个盒子,有水平向左和竖直向下的两种重力,求重力作用下的轮廓长度
D题不是我做的emm,貌似模拟就行
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 200010;
int a[N],b[N];
int main(){int n;cin>>n;ll cnt1=0,cnt2=0;while(n--){int x,y;cin>>x>>y;cnt1+=4;cnt2+=4;if(a[x]!=0) cnt1-=2;if(b[y]!=0) cnt2-=2;if(x!=0&&a[x]<a[x-1]) cnt1-=2;if(y!=0&&b[y]<b[y-1]) cnt2-=2;if(a[x]<a[x+1]) cnt1-=2;if(b[y]<b[y+1]) cnt2-=2;a[x]++;b[y]++;cout<<cnt1<<" "<<cnt2<<endl;}
}
G Grade Point Average
题目:输出数组a的平均数,要求小数点后k位
题解:
第一眼看成循环节,导致题目一直被卡,k在1e5以内,直接模拟就完事了
//蒟蒻三人行
#include<bits/stdc++.h>
#include<map>
typedef long long ll;
using namespace std;
const int maxn=1e6+9;
int a[maxn];
int l[maxn];
int cnt=0;
unordered_map<int,int>mp;
int main()
{int n,k;
// printf("%.15f",(1.0/7.0));scanf("%d%d",&n,&k);for(int i=1;i<=n;i++)cin>>a[i];double ave=0;int sum=0; for(int i=1;i<=n;i++){sum+=a[i];}printf("%d.",sum/n);int w=sum%n;int p=-1;for(int i=1;i<=k;i++){
// if(mp[(w*10)/n]==0){
// l[++cnt]=(w*10)/n;
// mp[(w*10)/n]=cnt;
// }
// else{
// p=mp[(w*10)/n];
// //break;
// }printf("%d",(w*10)/n);w=(w*10)%n;}
// if(p==-1){
// for(int i=1;i<=k;i++){
// printf("%d",l[i]);
// }
// }
// else{
// for(int i=1;i<=cnt;i++){
// printf("%d",l[i]);
// }
// int pp=cnt+1;
// int now=p;
// while(pp<=k){
// if(now==cnt+1){
// now=p;
// }
// printf("%d",l[now]);
// now++;
// pp++;
// }
// }/* int tot=0;ave=(w*1.0)/(1.0*n);while(k--){ave*=10;l[++tot]=(int)ave%10;ave/=10;}ave*=10;*/return 0;
}
H Adventurer’s Guild
裸的二维费用背包问题,直接套模板就行
#include<bits/stdc++.h>
#include<map>
typedef long long ll;
using namespace std;
const int maxn=1e3+9;
ll dp[maxn][maxn];
ll h[maxn],s[maxn],w[maxn];
int main()
{int n,H,S;cin>>n>>H>>S;for(int i=1;i<=n;i++)cin>>h[i]>>s[i]>>w[i];for(int i=1;i<=n;i++){for(int j=H;j>=0;j--){for(int k=S;k>=0;k--){if(j>h[i]&&k>=s[i])dp[j][k]=max(dp[j][k],dp[j-h[i]][k-s[i]]+w[i]);if(k<s[i]&&(j+k)>(s[i]+h[i]))dp[j][k]=max(dp[j][k],dp[j-h[i]-(s[i]-k)][0]+w[i]);}}}cout<<dp[H][S];
}