POJ炸了
所以放这里来
#include<cstdio> #include<cmath> #include<cstring> #include<string> #include<map> #include<queue> #include<vector> #include<stack> #include<algorithm> #include<iostream> #define max(a,b) (a>b?a:b) #define min(a,b) (a<b?a:b) #define N 12 int d[13], f[13]; using namespace std; int main() { d[1] = 1; for (int i = 2; i <= N; ++i) d[i] = 2 * d[i-1] + 1; memset(f, 0x3f, sizeof(f)); f[1] = 1,f[2]=3; for (int i = 1; i <= N; ++i) { for(int j=1;j<i;++j) f[i] = min(2 * f[j] + d[i - j], f[i]); printf("%d\n", f[i]); } return 0; }
原文地址:https://www.cnblogs.com/fsy2017/p/10049118.html
时间: 2024-10-12 14:05:03