提交记录 28325


用户 题目 状态 得分 用时 内存 语言 代码长度
zhaomumu1218 test. 自定义测试 Time Limit Exceeded 0 1 s 32 KB C++ 1.94 KB
提交时间 评测时间
2025-07-09 09:48:57 2025-07-09 09:49:01
#include<bits/stdc++.h>
using namespace std;
namespace IO{
	template<typename T>
	inline void read(T&x){
		x=0;
		bool f=0;
		char c=getchar();
		while(!isdigit(c)) c=='-'?f=1:0,c=getchar();
		while(isdigit(c)) x=x*10+c-'0',c=getchar();
		f?x=-x:0;
	}
	template<typename T>
	inline void write(T x){
		if(x==0){
			putchar('0');
			return ;
		}
		x<0?x=-x,putchar('-'):0;
		short top=0,st[100];
		while(x) st[++top]=x%10,x/=10;
		while(top) putchar(st[top--]+'0');
	}
	inline void read(char&x){
		x=getchar();
		while(isspace(x)) x=getchar();
	}
	inline void write(char x){
		putchar(x);
	}
	template<typename T>
	inline void write(T*x){
		while(*x) putchar(*(x++));
	}
	inline void read(string&s){
		s="";
		char c;
		read(c);
		while(!isspace(c)&&~c) s+=c,c=getchar();
	}
	inline void write(string s){
		for(int i=0,len=s.size();i<len;i++) putchar(s[i]);
	}
	template<typename T,typename...T2>
	inline void read(T&x,T2&...y){
		read(x),read(y...);
	}
	template<typename T,typename...T2>
	inline void write(const T x,const T2...y){
		write(x),putchar(' '),write(y...),sizeof...(y)==1?putchar('\n'):0;
	}
}using namespace IO;
int n,m,r[100],h[100],ans=100000000,sum[100],sumb[100];
void dfs(int u,int tj,int bmj=0,int ltr=-1,int lth=-1){
	if(bmj+sumb[u]>=ans) return ;
	if(tj+sum[u]>n) return ;
	if(u==m+1){
		if(tj==n){
			int q=bmj;
			ans=q;
		}
		return ;
	}
	if(~ltr&&tj+ltr*ltr*lth*(n-u+1)<n) return ;
	int maxr;
    if(ltr==-1) maxr=sqrt(n-tj-sum[u+1]); 
    else maxr=min(ltr-1,(int)sqrt(n-tj-sum[u+1])); 
	for(int i=maxr;i>=m-u+1;--i){
		int maxh,z=i*i;
		if(lth==-1) maxh=(n-tj-sum[u+1])/z;
		else maxh=min(lth-1,(n-tj-sum[u+1])/z);
		for(int j=maxh;j>=m-u+1;--j){
			int add=2*i*j;
			if(u==1) add+=z;
			dfs(u+1,tj+z*j,bmj+add,i,j);
		}
	}
}
signed main(){
        n=9876,m=6;
	for(int i=m;i>=1;i--) sum[i]=sum[i+1]+(m-i+1)*(m-i+1)*(m-i+1);
	for(int i=m;i>=1;i--) sumb[i]=sumb[i+1]+2*(m-i+1)*(m-i+1);
	dfs(1,0);
	if(ans==100000000) write(0);
	else write(ans);
	return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #11 s32 KBTime Limit ExceededScore: 0


Judge Duck Online | 评测鸭在线
Server Time: 2025-07-13 21:43:38 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠