[ZJ]d887: 1.山脈種類(chain)
題目:
http://zerojudge.tw/ShowProblem?problemid=d887
========================================================
#include<cstdio>
#include<cstring>
int main(void)
{
int n;
while(scanf("%d",&n)!=EOF)
{
long long int DP[30][30];
memset(DP,0,sizeof(DP));
DP[0][1] = 1;
for(int i=1;i<=n+1;i++)
{
for(int j=i;j<=n+1;j++)
DP[i][j] = DP[i-1][j] + DP[i][j-1];
}
printf("%lld\n",DP[n+1][n+1]);
}
return 0;
}
http://zerojudge.tw/ShowProblem?problemid=d887
========================================================
#include<cstdio>
#include<cstring>
int main(void)
{
int n;
while(scanf("%d",&n)!=EOF)
{
long long int DP[30][30];
memset(DP,0,sizeof(DP));
DP[0][1] = 1;
for(int i=1;i<=n+1;i++)
{
for(int j=i;j<=n+1;j++)
DP[i][j] = DP[i-1][j] + DP[i][j-1];
}
printf("%lld\n",DP[n+1][n+1]);
}
return 0;
}
留言
張貼留言