简单dp --- HDU1248寒冰王座

时间:2023-01-21 22:57:08

题目链接

这道题也是简单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 ;
}