标签:
解题源代码:
1 #include <stdio.h> 2 3 unsigned long long RoadWay(int n) { //定义了unsigned long long类型 4 unsigned long long num1=1lu, num2=2lu; 5 unsigned long long temp; 6 int i; 7 if(n == 2) { 8 return 1lu; 9 } else if(n==3){ 10 return 2lu; 11 } else { 12 for (i=4; i<=n; ++i) { 13 temp = num1 + num2; 14 num1 = num2; 15 num2 = temp; 16 } 17 return num2; 18 } 19 } 20 21 int main(int argc, const char * argv[]) { 22 // insert code here... 23 int n; 24 int a, b; 25 int len; 26 27 scanf("%d", &n); 28 29 while (n>0) { 30 scanf("%d%d", &a, &b); 31 if(a>0 && a< b && b<50) { 32 len = b-a; 33 printf("%I64d\n", RoadWay(1+len)); 34 } else { 35 break; 36 } 37 --n; 38 } 39 40 return 0; 41 }
问题总结:
标签:
原文地址:http://www.cnblogs.com/lunlv/p/4983292.html