HDU2193-AVL-数据结构-AVL
生活随笔
收集整理的這篇文章主要介紹了
HDU2193-AVL-数据结构-AVL
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
題目鏈接:http://acm.hdu.edu.cn/statistic.php?
pid=2193&from=126&lang=&order_type=0
好吧。水題一道,原本以為是一道寫AVL樹的想寫來練練手。沒有想到卻是這樣一道水題,好吧,猥瑣的水過。
題目意思:
題目大意:n個點的AVL樹最多有幾層。
遞推公式:?? a[i]=a[i-1]+a[i-2]+1;
#include<iostream> #include<string> #include<cstdio> #include<cstring> #include<queue> #include<map> #include<cmath> #include<stack> #include<set> #include<vector> #include<algorithm> #define LL long long #define inf 1<<30 #define s(a) scanf("%d",&a) #define CL(a,b) memset(a,b,sizeof(a)) using namespace std; const int N=45; int n,a[N],b; int main() {a[0]=1;a[1]=2;for(int i=2;i<=44;i++) a[i]=a[i-1]+a[i-2]+1;while(~scanf("%d",&n)&&n){int i=0;while(a[i]<=n) i++;printf("%d\n",--i);}return 0; }
?
總結
以上是生活随笔為你收集整理的HDU2193-AVL-数据结构-AVL的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python秒转换成小时分钟秒_新闻联播
- 下一篇: c primer plus 第6版 中文