QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#637153#9443. Left Equals Rightucup-team4992#WA 1ms5764kbC++20860b2024-10-13 10:17:352024-10-13 10:17:35

Judging History

你现在查看的是最新测评结果

  • [2024-10-13 10:17:35]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5764kb
  • [2024-10-13 10:17:35]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int MAXN = 100+5;
const ll mod = 998244353;
int n, s;
int a[MAXN];
ll ans = 0, fac[MAXN];
ll dp[MAXN][MAXN*MAXN];

int main(){
    cin >> n;
    fac[0] = 1;
    for(int i = 1; i <= n; i++){
        fac[i] = fac[i-1]*i%mod;
    }
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        s += a[i];
    }
    if(s & 1){
        cout << "0\n";
        return 0;
    }
    s /= 2;
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++){
        for(int j = i; j >= 1; j--){
            for(int k = 0; k <= 100*j; k++){
                dp[j][k] = (dp[j][k] + dp[j-1][k-a[i]]) % mod;
            }
        }
    }
    for(int i = 1; i < n; i++){
        ans = (ans + dp[i][s]*fac[i]%mod*fac[n-i]%mod);
    }
    cout << ans%mod << "\n";
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5764kb

input:

3
4 9 5

output:

973939548

result:

wrong answer 1st words differ - expected: '4', found: '973939548'