性感代码,在线求调
  • 板块P1120 小木棍
  • 楼主jhhh
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/11/25 17:04
  • 上次更新2024/11/25 19:57:03
查看原帖
性感代码,在线求调
502983
jhhh楼主2024/11/25 17:04

https://www.luogu.com.cn/record/191060557

#include<bits/stdc++.h>
using namespace std;
int n;
int stick[100];
int i;
int l,r,minn;
void dfs(int shen,int x) {
	
	if(shen==0) {//cout<<shen<<' '<<x<<endl;
		dfs(i,x-1);
		return;
	}
	if(x==0) {
		cout<<i<<endl;
		exit(0);
	}
	for(int j=l; j>=minn; j--) {
		if(!stick[j])continue;
		if(shen-j>=0) {
			dfs(shen-j,x);
		} else {
			continue;
		}
	}
}
int main() {
	cin>>n;
	l=r=0;
	for(int i=1; i<=n; i++) {
		int t;
		cin>>t;
		stick[t]++;
		l=max(l,t);
		r+=t;
		minn=min(minn,t);
	}
	for(i=l; i<=r; i++) {
		if(r%i==0)
			dfs(i,n);
	}
	return 0;
}

等待大佬,在线等,祝大佬rp++

2024/11/25 17:04
加载中...