結果

問題 No.1645 AB's abs
ユーザー GhostMFCGhostMFC
提出日時 2023-10-15 12:11:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 1,116 bytes
コンパイル時間 1,738 ms
コンパイル使用メモリ 165,004 KB
実行使用メモリ 12,228 KB
最終ジャッジ日時 2023-10-15 12:12:02
合計ジャッジ時間 4,007 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,372 KB
testcase_01 AC 2 ms
4,368 KB
testcase_02 AC 4 ms
7,352 KB
testcase_03 AC 1 ms
4,368 KB
testcase_04 AC 2 ms
4,368 KB
testcase_05 AC 2 ms
4,368 KB
testcase_06 AC 2 ms
4,372 KB
testcase_07 AC 2 ms
4,368 KB
testcase_08 AC 5 ms
7,360 KB
testcase_09 AC 5 ms
7,684 KB
testcase_10 AC 5 ms
7,416 KB
testcase_11 AC 5 ms
7,412 KB
testcase_12 AC 5 ms
7,684 KB
testcase_13 AC 8 ms
11,792 KB
testcase_14 AC 8 ms
11,512 KB
testcase_15 AC 8 ms
11,828 KB
testcase_16 AC 8 ms
11,524 KB
testcase_17 AC 8 ms
11,776 KB
testcase_18 AC 8 ms
11,580 KB
testcase_19 AC 8 ms
11,792 KB
testcase_20 AC 8 ms
11,660 KB
testcase_21 AC 8 ms
11,728 KB
testcase_22 AC 8 ms
11,832 KB
testcase_23 AC 8 ms
11,948 KB
testcase_24 AC 8 ms
11,932 KB
testcase_25 AC 8 ms
12,064 KB
testcase_26 AC 8 ms
12,144 KB
testcase_27 AC 9 ms
12,008 KB
testcase_28 AC 8 ms
11,956 KB
testcase_29 AC 9 ms
12,228 KB
testcase_30 AC 9 ms
12,000 KB
testcase_31 AC 9 ms
11,940 KB
testcase_32 AC 9 ms
12,060 KB
testcase_33 AC 9 ms
11,968 KB
testcase_34 AC 8 ms
12,136 KB
testcase_35 AC 9 ms
11,972 KB
testcase_36 AC 9 ms
11,976 KB
testcase_37 AC 9 ms
12,088 KB
testcase_38 AC 8 ms
11,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define ll long long
#define inf 0x7fffffff
#define ull unsigned long long
#define llinf 0x7fffffffffffffff
#define F(a,b,c,d) for(int b=c;b<=d;b+=a)
#define F2(a,b,c,d) for(int b=c;b>=d;b-=a)
#define PRC(b,a) fixed<<setprecision(a)<<b
#define pb push_back
#define All(x) x.begin(),x.end()
#define Next(a,b) for(int a=head[b];a;a=edge[a].nxt)
#define IOS ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
using namespace std;
inline ll Gcd(ll xx,ll yy){return yy?Gcd(yy,xx%yy):xx;}
inline ll q_Pow(ll xx,ll yy,ll pp){ll oo=1;for(;yy;yy>>=1,xx=xx*xx%pp)yy&1?oo=oo*xx%pp:0;return oo;}
inline void Cout(){cout<<endl;}
template <class T1,class...T2>
inline void Cout(T1 x,T2 ...y){cout<<x<<' ';Cout(y...);}

const int N=105,mod=998244353;

int n,a[N];
ll f[N][N*N];

signed main(){
  IOS

  cin>>n;
  for(int i=1;i<=n;++i) cin>>a[i];

  f[0][0]=1;
  for(int i=1;i<=n;++i)
    for(int j=0;j<=10000;++j){
      f[i][j+a[i]]+=f[i-1][j]%=mod;
      f[i][abs(j-a[i])]+=f[i-1][j]%=mod;
    }

  ll ans=0;
  for(int i=0;i<=10000;++i) ans=(ans+f[n][i]*i)%mod;
  cout<<ans<<'\n';
  
  return 0;
}
0