#21702: 求救


s10806226@smail.ycsh.tp.edu.tw (Eri)

學校 : 臺北市立永春高級中學
編號 : 108040
來源 : [101.3.116.101]
最後登入時間 :
2022-05-11 14:14:13
b229. TOI2009 第一題:路徑問題 -- 2009TOI研習營初選 | From: [203.72.61.164] | 發表日期 : 2020-07-09 11:40

#include <bits/stdc++.h>

 

using namespace std;

 

unsigned long long int f(unsigned long long int x){

    if(x==0)return 1;

    else if(x==1)return 3;

    else return 2*f(x-1)+f(x-2);

}

 

int main()

{

    unsigned long long int n;

    cin>>n;

    cout<<f(n)<<"\n";

    return 0;

}

 

n=50跑不出來

 

 
#21703: Re:求救


s10806226@smail.ycsh.tp.edu.tw (Eri)

學校 : 臺北市立永春高級中學
編號 : 108040
來源 : [101.3.116.101]
最後登入時間 :
2022-05-11 14:14:13
b229. TOI2009 第一題:路徑問題 -- 2009TOI研習營初選 | From: [203.72.61.164] | 發表日期 : 2020-07-09 11:46

#include <bits/stdc++.h>

 

using namespace std;

 

unsigned long long int f(unsigned long long int x){

    if(x==0)return 1;

    else if(x==1)return 3;

    else return 2*f(x-1)+f(x-2);

}

 

int main()

{

    unsigned long long int n;

    cin>>n;

    cout<<f(n)<<"\n";

    return 0;

}

 

可以跑出來 但會TLE

 



 
#21725: Re:求救


s10806226@smail.ycsh.tp.edu.tw (Eri)

學校 : 臺北市立永春高級中學
編號 : 108040
來源 : [101.3.116.101]
最後登入時間 :
2022-05-11 14:14:13
b229. TOI2009 第一題:路徑問題 -- 2009TOI研習營初選 | From: [219.91.14.225] | 發表日期 : 2020-07-12 17:24

#include <bits/stdc++.h>

 

using namespace std;

 

unsigned long long int f(unsigned long long int x){

    if(x==0)return 1;

    else if(x==1)return 3;

    else return 2*f(x-1)+f(x-2);

}

 

int main()

{

    unsigned long long int n;

    cin>>n;

    cout<<f(n)<<"\n";

    return 0;

}

 

可以跑出來 但會TLE

 

 

沒事 解決了

 



 
ZeroJudge Forum