求助!!!在线等!!
查看原帖
求助!!!在线等!!
575755
nopic楼主2022/7/23 09:48
#include<bits/stdc++.h>
#define ll long long
using namespace std;
inline ll read()
{
    ll sum=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9')
    {
        sum=(sum<<1)+(sum<<3)+(c^48);
        c=getchar(); 
    }
    return sum*f;
}//快读 
ll pi=1,n,m,ans=8177919,a[100][3];//pi只是挂个空壳 
void dfs(ll nows,ll nowr,ll nowh,ll nowv,ll stemp)//目前面积,半径,高,体积,层数 
{
	if(stemp==m&&nowv==pi*n){
		if(ans>nows)
			ans=nows;
		return;
	}
	if(nows>=ans)//剪枝 
		return;
	if(nowv>=n*pi)//剪枝
		return;
	if(stemp>=m)//剪枝
		return;
	for(ll i=1;i<=nowr-1;i++){
		for(ll j=1;j<=nowh-1;j++){
			if(stemp==1)
				nows+=pi*i*i;
			nowv+=pi*i*i*j;
			nows+=pi*i*2*j;
			cout<<stemp<<' '<<nowr<<' '<<nowh<<' '<<ans<<' '<<nows<<' '<<nowv<<' '<<endl; 
			dfs(nows,i,j,nowv,stemp+1);
			nowv=0;
			nows=0;
		}
	}
}

int main(){
	n=read();
	m=read();
	dfs(0,sqrt(n),sqrt(n),0,1);
	printf("%d",ans/pi);
    return 0;
}

半径,高,层数有问题!! 求大佬帮助

2022/7/23 09:48
加载中...