#include <stdio.h>
int main()
{
int x,i;
long arr[31];
long arr2[31];
arr[0] = arr2[1] = 1;
arr[1] = arr2[0] = 0;
for (i = 2; i < 31; i++) {
arr[i] = arr[i - 2] + 2 * arr2[i - 1];
arr2[i] = arr[i - 1] + arr2[i - 2];
}
while(1){
scanf("%d",&x);
if(x<0){
break;
}
if(x%2==1){
puts("0");
}else{
printf("%ld\n",arr[x]+arr2[x]);
}
}
return 0;
}
int main()
{
int x,i;
long arr[31];
long arr2[31];
arr[0] = arr2[1] = 1;
arr[1] = arr2[0] = 0;
for (i = 2; i < 31; i++) {
arr[i] = arr[i - 2] + 2 * arr2[i - 1];
arr2[i] = arr[i - 1] + arr2[i - 2];
}
while(1){
scanf("%d",&x);
if(x<0){
break;
}
if(x%2==1){
puts("0");
}else{
printf("%ld\n",arr[x]+arr2[x]);
}
}
return 0;
}
No comments:
Post a Comment