标签:
PS:递推题.. a[n]=a[n-1]*3+2*b[n-1] b[n]=a[n-1]+b[n-1]
代码:
#include "stdio.h" long long a[35]; long long b[35]; int main(){ int i,c; a[0]=1; b[0]=0; for(i=1;i<35;i++){ a[i]=3*a[i-1]+2*b[i-1]; b[i]=b[i-1]+a[i-1]; } while(~scanf("%d",&c)){ if(c==-1) return 0; printf("%lld, %lld\n",a[c],b[c]); } return 0; }
标签:
原文地址:http://www.cnblogs.com/sureli/p/5271007.html