結果

問題 No.1645 AB's abs
ユーザー pengin_2000pengin_2000
提出日時 2021-08-13 21:38:44
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 719 bytes
コンパイル時間 1,030 ms
コンパイル使用メモリ 30,720 KB
実行使用メモリ 9,856 KB
最終ジャッジ日時 2024-04-14 17:10:21
合計ジャッジ時間 1,423 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 3 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 4 ms
6,940 KB
testcase_09 AC 4 ms
6,944 KB
testcase_10 AC 4 ms
6,940 KB
testcase_11 AC 3 ms
6,944 KB
testcase_12 AC 3 ms
6,940 KB
testcase_13 AC 7 ms
9,544 KB
testcase_14 AC 6 ms
8,984 KB
testcase_15 AC 7 ms
9,552 KB
testcase_16 AC 6 ms
9,276 KB
testcase_17 AC 7 ms
9,492 KB
testcase_18 AC 6 ms
9,192 KB
testcase_19 AC 6 ms
9,556 KB
testcase_20 AC 7 ms
8,968 KB
testcase_21 AC 6 ms
9,240 KB
testcase_22 AC 8 ms
9,352 KB
testcase_23 AC 9 ms
9,708 KB
testcase_24 AC 6 ms
9,720 KB
testcase_25 AC 6 ms
9,748 KB
testcase_26 AC 7 ms
9,692 KB
testcase_27 AC 7 ms
9,756 KB
testcase_28 AC 7 ms
9,712 KB
testcase_29 AC 7 ms
9,740 KB
testcase_30 AC 6 ms
9,696 KB
testcase_31 AC 8 ms
9,752 KB
testcase_32 AC 7 ms
9,744 KB
testcase_33 AC 7 ms
9,856 KB
testcase_34 AC 7 ms
9,560 KB
testcase_35 AC 7 ms
9,708 KB
testcase_36 AC 7 ms
9,608 KB
testcase_37 AC 7 ms
9,704 KB
testcase_38 AC 7 ms
9,728 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:2:15: warning: conflicting types for built-in function 'abs'; expected 'int(int)' [-Wbuiltin-declaration-mismatch]
    2 | long long int abs(long long int n)
      |               ^~~
main.c:2:1: note: 'abs' is declared in header '<stdlib.h>'
    1 | #include<stdio.h>
  +++ |+#include <stdlib.h>
    2 | long long int abs(long long int n)

ソースコード

diff #

#include<stdio.h>
long long int abs(long long int n)
{
	if (n < 0)
		n *= -1;
	return n;
}
int main()
{
	long long int n;
	scanf("%lld", &n);
	long long int i, j;
	long long int a[102];
	for (i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	long long int p = 998244353;
	long long int dp[102][10004];
	for (i = 0; i <= n; i++)
		for (j = 0; j < 10004; j++)
			dp[i][j] = 0;
	dp[0][0]= 1;
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < 10004; j++)
		{
			dp[i + 1][j + a[i]] += dp[i][j];
			dp[i + 1][j + a[i]] %= p;
			dp[i + 1][abs(j - a[i])] += dp[i][j];
			dp[i + 1][abs(j - a[i])] %= p;
		}
	}
	long long int ans = 0;
	for (j = 0; j < 10004; j++)
		ans = (ans + j * dp[n][j] % p) % p;
	printf("%lld\n", ans);
	return 0;
}
0