记录程序(递归考试第三题

ykj12 2022-05-29 16:30:07 0
#include<bits/stdc++.h>
using namespace std;
int n1,sum=1,fa;
int cont;
void dfs(int x){
	fa=0;
	sum*=x;
	if(sum==n1){
		cont++;
		sum/=x;
	}
	else if(sum<n1){
		for(int i=2;i<=n1/2;i++){
			if(n1%i==0&&i>=x&&sum*i<=n1){
				dfs(i);
			}
		}
		sum=sum/x;
	}
}
int main(){
	freopen("factor.in","r",stdin);
	freopen("factor.out","w",stdout);
	cont=0;
	cin>>n1;
	dfs(1);
	cout<<cont+1<<endl;
	return 0;
}

分解因数(oj上面照样没有 AC了

{{ vote && vote.total.up }}