来自一位新手的困惑
查看原帖
来自一位新手的困惑
490296
YZ9551楼主2021/9/25 11:48

为什么我同样提交了两次一模一样的代码,一次过了一次一部分RE了

应该不算题解吧,我这个有一次没过 记录:

过了的那一次

没过的那一次

有dalao可以告诉我为什么第一次有一部分RE了吗

下面是代码:

#include<iostream>
using namespace std;
int ans[1005];
int find(int first){
	if(ans[first] != 0){
		return ans[first];
	}
	if(first == 1){
		return 1;
	}
	int res = 1;
	for(int i = 1; i * 2 <= first; i++){
		res += find(i);
	}
	//cout<<"find("<<first<<")"<<res<<endl;
	ans[first] = res;
	return res;
}
int main(){
	int n;
	cin>>n;
	int cnt = 0;
	cnt = find(n);
	cout<<cnt;
	return 0;
}
2021/9/25 11:48
加载中...