Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
149272 吴悠 三角形 C++ 解答错误 20 11 MS 1052 KB 852 2024-05-26 12:16:46

Tests(2/10):


#include<iostream> #include<cmath> using namespace std; int ed[41]; bool dp[801][801]; bool judge(int a,int b,int c){ if(a+b>c && a+c>b && b+c>a){ return true; } else return false; } double S(int a,int b,int c){ int p=(a+b+c)/2; return sqrt(p*(p-a)*(p-b)*(p-c)); } int main(){ int n,sum=0; double maxs=0; cin>>n; for(int i=1;i<=n;i++){ cin>>ed[i]; sum+=ed[i]; } dp[0][0]=true; for(int i=1;i<=n;i++){ for(int a=sum/2;a>=0;a--){ for(int b=sum/2;b>=0;b--){ if(ed[i]<=a){ dp[a][b]=dp[a-ed[i]][b]; } if(ed[i]<=b){ dp[a][b]=dp[a][b-ed[i]]; } } } } for(int a=1;a<=sum/2;a++){ for(int b=1;b<=sum/2;b++){ int c=sum-a-b; if(c>0 && dp[a][b]==true && judge(a,b,c)==true){ maxs=max(maxs,S(a,b,c)); } } } cout<<int(maxs*100)<<endl; return 0; }


测评信息: