# Fibonaccimal Base 題目連結 [UVa 948](https://onlinejudge.org/external/9/948.pdf) ## 中文簡述 以Fib當作進位制 ## solution: ``` #include<iostream> using namespace std; int main() { int i,j,fib[40]={0}; fib[0]=fib[1]=1; for(i=0;i<38;i++) { fib[i+2]=fib[i+1]+fib[i]; } int n; while(cin>>n) { while(n--) { int m; cin>>m; int move=39,res[40]={0}; cout<<m<<" = "; for(i=39;i>=0;i--) { while(m>=fib[i]) { res[i]++; m-=fib[i]; } } for(i=39;i>=0;i--) { if(res[i]) { move=i; break; } } for(i=move;i>=1;i--) { cout<<res[i]; } cout << " (fib)" << endl; } } } ``` ###### tags: `UVA` 回目錄 [學習筆記](/gIBZqAbWTCis7uOPp149gA)
×
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