Hello World
Saturday 5 May 2012
UVa 900 Brick Wall Patterns Solution
#include<stdio.h>
int main()
{
long long int n,i,a[100000];
while(scanf("%lld",&n)==1)
{
if(n==0) break;
a[1]=1;
a[2]=2;
for(i=3;i<=n;i++)
a[i]=a[i-2]+a[i-1];
printf("%lld\n",a[n]);
}
return 0;
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment