Original | Transformed |
4 5
Original | Transformed |
3 5
#include <stdio.h> int main(int argc, char *argv[]) { int n,a,b,k,l,r; while(scanf("%d",&n)!=EOF){ if(n==1) printf("1\n"); if(n==2) printf("1\n"); if(n>2){ a=1,b=1,k=n-2; while(k--){ l=a+b; r=a;a=b;b=r;b=l; } printf("%d\n",l); } } return 0; } /* 联想走楼梯; A8=A7+A5+A3+A1 A7=A6+A4+A2+1; */
原文地址:http://blog.csdn.net/wangjia_to_dream/article/details/24913781