求各位大佬帮忙优化一下,悬关
  • 板块学术版
  • 楼主naroto2022
  • 当前回复1
  • 已保存回复1
  • 发布时间2024/3/24 15:42
  • 上次更新2024/3/24 17:24:03
查看原帖
求各位大佬帮忙优化一下,悬关
734703
naroto2022楼主2024/3/24 15:42
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define mod 998244353
using namespace std;
long long n,m,ans,a[1000005];
void dfs(long long step){
	for(int i=1; i<=m; i++){
		a[step]=i;
		if(step<n) dfs(step+1);
		else{
			for(int x=1; x<=n; x++)
				for(int y=x+1; y<=n; y++)
					ans=(ans+(a[x]+a[y])/2)%mod;
		}
	}
}
int main(){
	scanf("%lld %lld",&n,&m);
	dfs(1);
	printf("%lld",ans);
	return 0;
}

这段代码就是求 ai∈[1,m]a_i\in[1,m] 的每种情况的每个数对的平均值的和,帮下忙吧~~~

2024/3/24 15:42
加载中...