递推DP URAL 1260 Nudnik Photographer

时间:2021-10-02 20:53:37

题目传送门

 /*
递推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 ;
}