优化什么
by Rieman_sum @ 2023-08-24 15:39:32
程序,过不了
by yzh___nb @ 2023-08-24 15:42:24
帮忙改一下
by yzh___nb @ 2023-08-24 15:46:26
@[yzh___nb](/user/975048) 那你这应该叫调代码
我把我的代码给你参考一下
```cpp
#include <bits/stdc++.h>
using namespace std;
int n,f[1010];
int sol(int x)
{
int ans=1;
if(f[x]!=-1) return f[x];
for(int i=1;i<=x/2;i++)
{
ans+=sol(i);
}
return f[x]=ans;
}
int main()
{
cin>>n;
memset(f,-1,sizeof(f));
f[1]=1;
cout<<sol(n)<<endl;
return 0;
}
```
by coderJerry @ 2023-08-24 15:48:28
@[yzh___nb](/user/975048) 你的数组没开够,一开始也没有memset
by coderJerry @ 2023-08-24 15:49:21
@[yzh___nb](/user/975048) 还有,你要看清楚输入格式
by coderJerry @ 2023-08-24 15:50:05
coderJerry 谢谢你,关注了
by yzh___nb @ 2023-08-24 15:51:51
@[coderJerry](/user/953589) ```c
#include <stdio.h>
#include <string.h>
int i=0;
int s(int a){
if(a==1){
return 1;
}
if(a>1){
for(int b=1;b<=a/2;b++){
s(b);
}
i++;
}
}
int main(){
int a,c=0;
scanf("%d",&a);
c+=s(a);
printf("%d",c+i);
return 0;
}
```
by adoufw @ 2023-12-02 15:16:25
好像不需要开long long
by huyiheng @ 2023-12-03 11:54:27