#28820: CPP


11030067@mail.hpsh.tp.edu.tw (和平110級鄧雨珊)

學校 : 臺北市立和平高級中學
編號 : 163096
來源 : [61.64.210.174]
最後登入時間 :
2022-10-23 16:54:59
b837. 104北二1費氏數列 -- 104北二區桃竹苗基資訊學科能力複賽 | From: [219.85.132.64] | 發表日期 : 2022-01-05 23:33

#include <iostream>
using namespace std;

int main() {
int t, a, b, f[50]={0, 1}, i=1;
while (f[i]<1000000){
i++;
f[i]=f[i-1]+f[i-2];
}
cin >> t;
while (t--){
cin >> a >> b;
if (a>b){
swap(a, b);
}
int count=0;
i=0;
while (f[i]<=b){
if (f[i]>=a){
count++;
cout << f[i] <<endl;
}
i++;
}
cout << count <<endl;
if (t!=0){
cout <<"------\n";
}
}
}
 
ZeroJudge Forum