其他分享
首页 > 其他分享> > 一本通1316 数的计数

一本通1316 数的计数

作者:互联网

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <iterator>
#include <vector>
#define maxn 10000005
typedef long long ll;
using namespace std;
int n;

/*
 普通递归时间复杂度太高
 改用记忆化搜索
 */ 
//ll ans=1;
//void fun(int n){
//    if(n/2==0){
//        
//        return;
//    }else{
//        for(int i=1;i<=n/2;i++){
//            ans++;
//        //    cout<<i<<endl;
//            fun(i);
//        }
//    }
//}
int h[1001]; 
void fun(int n){
    if(h[n]!=-1) return;
    h[n]=1;
    for(int i=1;i<=n/2;i++){
        fun(i);
        h[n]=h[n]+h[i];
    }
}
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        h[i]=-1;
    }
    fun(n);
    cout<<h[n]; 
    return 0;
}

 

标签:1316,10000005,int,ll,long,计数,一本,include,复杂度
来源: https://www.cnblogs.com/lwx11111/p/15924667.html