洛谷-P1028 数的计算
作者:互联网
暴力递归,直接GG
#include<cstdio> #include<iostream> #include<algorithm> using namespace std; int tmp[1005]; int ans = 0; void fuc(int n){ if(n == 1){ return; } int tmp = n/2; for(int i=1;i<=tmp;i++){ ans++; fuc(i); } } int main(void){ int n; cin >> n; fuc(n); ans++; cout << ans; return 0; }
递推AC
#include<cstdio> #include<iostream> #include<algorithm> using namespace std; int ans = 0; int tmp[1005]; int main(void){ int n; cin >> n; for(int i=1;i<=n;i++){ for(int j=1;j<=i/2;j++){ tmp[i] += tmp[j]; } tmp[i]++; } cout << tmp[n]; return 0; }
标签:tmp,洛谷,int,void,namespace,计算,ans,include,P1028 来源: https://www.cnblogs.com/doubest/p/10843972.html