为什么这个点输出为0?
查看原帖
为什么这个点输出为0?
305002
vegetable_ste楼主2021/11/5 15:40

Code:

(注:提交的时候已经开了long long)

#include <bits/stdc++.h>
using namespace std;
const int N = 210;
int n, k, a[N], b[N], res;
int dp[N][7050];
int main() {
	#ifdef debug
//	freopen("round.in", "r", stdin);
//	freopen("round.out", "w", stdout);
	#endif
	memset(dp, -1, sizeof dp);
	dp[0][0] = 0;
	cin >> n >> k;
	for(int i = 1; i <= n; i ++ ) {
		long long x; cin >> x;
		while(!(x & 1)) { a[i] ++ ; x >>= 1; }
		while(!(x % 5)) { b[i] ++ ; x /= 5; }
	}
	for(int i = 1; i <= n; i ++ )
		for(int j = k; j >= 1; j -- )
			for(int k = 7000; k >= a[i]; k -- )
				if(dp[j - 1][k - a[i]] != -1)
					dp[j][k] = max(dp[j][k], dp[j - 1][k - a[i]] + b[i]);
	for(int i = 1; i <= 7000; i ++ ) res = max(res, min(dp[k][i], i));
	cout << res << endl;
	return 0;
}
2021/11/5 15:40
加载中...