简单dp --- HDU1248寒冰王座

题目链接

这道题也是简单dp里面的一种经典类型,递推式就是dp[i] = min(dp[i-150], dp[i-200], dp[i-350])

代码如下:

 #include<iostream>
#include <stdio.h>
using namespace std;
int dp[];
int main()
{
for (int i = ; i < ; i++)
dp[i] = i;
for (int i = ; i < ; i++)
{
int minn;
if (i < )
dp[i] = dp[i - ];
else if (i < )
dp[i] = min(dp[i - ], dp[i - ]);
else
{ minn = min(dp[i - ], dp[i - ]);
minn = min(minn, dp[i - ]);
dp[i] = minn;
}
}
int t;
scanf("%d", &t);
while (t--)
{
int n;
scanf("%d", &n);
printf("%d\n", dp[n]);
} return ;
}
上一篇:bzoj1816: [Cqoi2010]扑克牌(二分答案判断)


下一篇:[iOS Animation]-CALayer 图层树