递推DP URAL 1260 Nudnik Photographer

题目传送门

 /*
递推DP: dp[i] 表示放i的方案数,最后累加前n-2的数字的方案数
*/
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std; const int MAXN = 1e4 + ;
const int INF = 0x3f3f3f3f;
int dp[]; int main(void) //URAL 1260 Nudnik Photographer
{
//freopen ("G.in", "r", stdin); int n;
while (scanf ("%d", &n) == )
{
memset (dp, , sizeof (dp));
dp[] = ;
for (int i=; i<=n; ++i)
{
dp[i] = dp[i-];
if (i > )
{
dp[i] += dp[i-];
}
} long long ans = dp[n];
if (n > )
{
for (int i=; i<=n-; ++i) ans += dp[i];
}
printf ("%I64d\n", ans);
} return ;
}
上一篇:递推DP URAL 1167 Bicolored Horses


下一篇:JVM中的新生代、老年代和永生代