一如既往地菜...
a.
b.
#include <bits/stdc++.h> using namespace std; double point[105]; double dp[5][405]; int main(){ /* ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); */ memset(dp,0,sizeof(dp)); for(int i=0;i<=100;i++){ if(i>=0&&i<=59) point[i]=0.0; if(i>=60&&i<=61) point[i]=1.0; if(i>=62&&i<=64) point[i]=1.7; if(i>=65&&i<=66) point[i]=2.0; if(i>=67&&i<=69) point[i]=2.3; if(i>=70&&i<=74) point[i]=2.7; if(i>=75&&i<=79) point[i]=3.0; if(i>=80&&i<=84) point[i]=3.3; if(i>=85&&i<=89) point[i]=3.7; if(i>=90&&i<=94) point[i]=4.0; if(i>=95&&i<=100) point[i]=4.3; } for(int j=1;j<=4;j++){ for(int i=0;i<=100*j;i++){ for(int k=0;k<=min(i,100);k++){ dp[j][i]=max(dp[j][i],dp[j-1][i-k]+point[k]); } } } int t,x; cin>>t; while(t--){ cin>>x; printf("%.1f ",dp[4][x]); } return 0; }
c.
#include <bits/stdc++.h> using namespace std; int dp[1005][1005]; bool huzhi(int j,int k){ int r=j%k; while(r){ j=k; k=r; r=j%k; } if(k==1){ return true; }else{ return false; } } int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; int a,b; for(int j=1;j<=1000;j++){ dp[j][1]=j; } for(int j=1;j<=1000;j++){ dp[1][j]=j; } for(int j=2;j<=1000;j++){ for(int k=2;k<=1000;k++){ if(huzhi(j,k)){ dp[j][k]=max(dp[j-1][k],dp[j][k-1])+1; }else{ dp[j][k]=max(dp[j-1][k],dp[j][k-1]); } } } cin>>t; for(int i=0;i<t;i++){ cin>>a>>b; cout<<dp[a][b]<<endl; } return 0; }