--- title: 6A 費式數列 tags: solution --- # A. 費式數列(Easy) 因為數量級還很小,所以直接使用遞迴的方式即可處理: ```cpp= #include <iostream> using namespace std; int fib(int n){ if(n<=2) return 1; return fib(n-1)+fib(n-2); } int main() { int n; cin>>n; cout<<fib(n)<<'\n'; } ``` 註:用Python會TLE
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up