蜜蜂的路线选择法

来源:互联网 发布:linux rar压缩文件 编辑:程序博客网 时间:2024/04/28 11:20

Problem ITime Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 103   Accepted Submission(s) : 26Font: Times New Roman | Verdana | GeorgiaFont Size: ← →Problem Description有一只经过训练的蜜蜂只能爬向右侧相邻的蜂房,不能反向爬行。请编程计算蜜蜂从蜂房a爬到蜂房b的可能路线数。其中,蜂房的结构如下所示。Input输入数据的第一行是一个整数N,表示测试实例的个数,然后是N 行数据,每行包含两个整数a和b(0<a<b<50)。Output对于每个测试实例,请输出蜜蜂从蜂房a爬到蜂房b的可能路线数,每个实例的输出占一行。Sample Input21 23 6Sample Output13#include <iostream>using namespace std;int main(){    int  i,a,b,n;    long long temp,f1,f2;    cin>>n;    while(n--)    {        cin>>a>>b;        f1=0;        f2=1;        for(i=0; i<b-a; i++)        {            temp=f1+f2;            f1=f2;            f2=temp;        }        cout<<f2<<endl;    }    return 0;}

为什么temp,f1,f2定义为int 就是wrong answer,定义为long long 就是accept疑问

0 0
原创粉丝点击