#11104: 求救!OLE


fdhs103cobr (poisu)

學校 : 桃園市私立復旦高級中學
編號 : 49290
來源 : [59.115.86.177]
最後登入時間 :
2020-04-12 18:02:46
b837. 104北二1費氏數列 -- 104北二區桃竹苗基資訊學科能力複賽 | From: [220.135.43.161] | 發表日期 : 2016-06-28 13:28

#include <iostream>
using namespace std;
bool t[1000000]={0};
int f(int n){
if(n==0){
return 0;
}
else if(n==1){
return 1;
}
else{
return f(n-2)+f(n-1);
}
}
void Set(){
for(int i=0;i<1000;i++){
int g=f(i);
if(g>=1000000){
break;
}
else{
t[g]=true;
}
}
}
int main(){
Set();
int k;
while(cin>>k){
for(int p=0;p<k;p++){
int a,b;
cin>>a>>b;
if(a>b){
int g=b;
b=a;
a=g;
}
int count=0;
for(int i=a;i<=b;i++){
if(t[i]){
cout<<i<<endl;
if(i==1){
cout<<1<<endl;
count++;
}
count++;
}
}
cout<<count<<endl;
cout<<"------"<<endl;
}
}

}

基本上判斷沒什麼問題,我自己測試輸出都正常,依照題意加上分隔線卻吃了OLE

可以請高手幫我檢查哪邊出錯嗎?

 
#11105: Re:求救!OLE


fdhs103cobr (poisu)

學校 : 桃園市私立復旦高級中學
編號 : 49290
來源 : [59.115.86.177]
最後登入時間 :
2020-04-12 18:02:46
b837. 104北二1費氏數列 -- 104北二區桃竹苗基資訊學科能力複賽 | From: [220.135.43.161] | 發表日期 : 2016-06-28 13:39

#include
using namespace std;
bool t[1000000]={0};
int f(int n){
if(n==0){
return 0;
}
else if(n==1){
return 1;
}
else{
return f(n-2)+f(n-1);
}
}
void Set(){
for(int i=0;i<1000;i++){
int g=f(i);
if(g>=1000000){
break;
}
else{
t[g]=true;
}
}
}
int main(){
Set();
int k;
while(cin>>k){
for(int p=0;p<k;p++){
int a,b;
cin>>a>>b;
if(a>b){
int g=b;
b=a;
a=g;
}
int count=0;
for(int i=a;i<=b;i++){
if(t[i]){
cout<<i<<endl;
if(i==1){
cout<<1<<endl;
count++;
}
count++;
}
}
cout<<count<<endl;
cout<<"------"<<endl;
}
}

}

基本上判斷沒什麼問題,我自己測試輸出都正常,依照題意加上分隔線卻吃了OLE

可以請高手幫我檢查哪邊出錯嗎?

已經不用了,我發現最後一筆不用加分隔線....

害我找了好久

 
ZeroJudge Forum