标签:php png amp ihe std sqrt int eof src
http://acm.hi-54.com/problem.php?pid=2131
很简单 只需要考虑三种状态即可。
计算10*10的计算图如下
普通思维是这种100 这个才是最优的106
计算方法也就出来了
#include<cstdio> #include<cstring> #include<algorithm> #include<iostream> #include<queue> #include<map> #include<vector> #include<math.h> #include<string> #include<time.h> using namespace std; #define INF 0x3f3f3f3f #define LL long long #define N 10000009 #define mid 10000000 int maxx=0; double jihe=sqrt(3.0)/2; void dfs(int e,double n,int m,double h,int t)///分别表示上一行的状态,总高度,每行最多个数,当前高度,当前圆的个数 { if(h+jihe>n) return ; if(e==0&&h+1<=n)///直接在上面放m个长度+1 { maxx=max(maxx,t+m); dfs(0,n,m,h+1,t+m); } maxx=max(maxx,t+m-(e+1)%2); ///直接在上面放m个或者m-1 长度同为sqrt(3)/2 dfs((e+1)%2,n,m,h+jihe,t+m-(e+1)%2); } int main() { int n,m; while(scanf("%d%d",&n,&m)!=EOF) { maxx=n*m; dfs(0,n,m,1,m); swap(n,m);///要遍历两次 才能够得到最优解 dfs(0,n,m,1,m); printf("%d\n",maxx); } return 0; }
标签:php png amp ihe std sqrt int eof src
原文地址:https://www.cnblogs.com/a719525932/p/9496332.html