URAL 1079 Maximum 递推
2016-09-07 10:53
204 查看
本题直接按照题意递推,也可以用记忆化搜索
#include<iostream> using namespace std; int a[100000],f[100000]; int main(){ int i,ans=1; a[0]=0; a[1]=1; f[0]=0; f[1]=1; for(i=2; i<=99999; i++) { if(i&1) a[i]=a[i/2]+a[i/2+1]; else a[i]=a[i/2]; ans=max(ans,a[i]); f[i]=ans; } while(1){ int n; cin>>n; if(!n)break; cout<<f <<endl; } return 0; }
相关文章推荐
- URAL1079:Maximum
- Ural 1079 - Maximum
- Ural1079-Maximum
- Maximum Value Problem FZU 2037 找规律 递推
- 递推-nyoj-The number of maximum subset
- URAL 1309 Dispute <函数关系的递推>
- 面相对象的topSort和递推【ural1022/ural1017】
- URAL 1513. Lemon Tale(简单的递推)
- Ural 1309 Dispute (递推)
- URAL 1225-Flags(规律递推)
- 递推DP URAL 1031 Railway Tickets
- URAL 1225 递推
- URAL 1009 K-based numbers(DP递推)
- URAL 1009. K-based Numbers(简单递推)
- 递推DP URAL 1225 Flags
- 递推DP URAL 1081 Binary Lexicographic Sequence
- URAL 1225(Flags)简单递推
- URAL 1017. Staircases(递推)
- URAL 1513. Lemon Tale(简单的递推)
- 递推DP URAL 1009 K-based Numbers