em xin code với ý tưởng ạ, em dùng qhd mà test ra sai ạ
__Code em ạ:
// Online C++ compiler to run C++ program online
#include <bits/stdc++.h>
using namespace std;
int main() {
// Write C++ code here
int n, s=0; cin >> n;
vector <int> a;
for(int i=1; i<=n; i++){
s+=i;
a.push_back(i);
}
vector<int> dp(s+1,0);
dp[0]=1;
for(int i=0; i<n; i++){
for(int j=s; j>=a[i]; j--){
if(dp[j-a[i]]!=0){
dp[j]++;
}
// cout << dp[j] << " ";
}
// cout << endl;
}
int ans = -1e9;
for(int i=0; i<=s; i++){
ans = max(ans,dp[i]);
// cout << dp[i] << " ";
}
int k = 1e9+7;
cout << (ans/2)%k << endl;
return 0;
}