結果

問題 No.1633 Sorting Integers (Multiple of 2^K)
ユーザー bal4ubal4u
提出日時 2021-08-10 12:32:05
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 649 bytes
コンパイル時間 1,710 ms
コンパイル使用メモリ 29,340 KB
実行使用メモリ 4,368 KB
最終ジャッジ日時 2023-10-23 20:10:07
合計ジャッジ時間 4,265 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,368 KB
testcase_01 AC 1 ms
4,368 KB
testcase_02 AC 1 ms
4,368 KB
testcase_03 AC 1 ms
4,368 KB
testcase_04 AC 1 ms
4,368 KB
testcase_05 AC 1 ms
4,368 KB
testcase_06 AC 1 ms
4,368 KB
testcase_07 AC 1 ms
4,368 KB
testcase_08 AC 1 ms
4,368 KB
testcase_09 AC 1 ms
4,368 KB
testcase_10 AC 1 ms
4,368 KB
testcase_11 AC 1 ms
4,368 KB
testcase_12 AC 1 ms
4,368 KB
testcase_13 AC 1 ms
4,368 KB
testcase_14 AC 1 ms
4,368 KB
testcase_15 AC 1 ms
4,368 KB
testcase_16 AC 1 ms
4,368 KB
testcase_17 AC 1 ms
4,368 KB
testcase_18 AC 1 ms
4,368 KB
testcase_19 AC 1 ms
4,368 KB
testcase_20 AC 1 ms
4,368 KB
testcase_21 AC 1 ms
4,368 KB
testcase_22 AC 1 ms
4,368 KB
testcase_23 AC 45 ms
4,368 KB
testcase_24 AC 50 ms
4,368 KB
testcase_25 AC 52 ms
4,368 KB
testcase_26 AC 45 ms
4,368 KB
testcase_27 AC 49 ms
4,368 KB
testcase_28 AC 40 ms
4,368 KB
testcase_29 AC 49 ms
4,368 KB
testcase_30 AC 41 ms
4,368 KB
testcase_31 AC 45 ms
4,368 KB
testcase_32 AC 30 ms
4,368 KB
testcase_33 AC 2 ms
4,368 KB
testcase_34 AC 1 ms
4,368 KB
testcase_35 AC 3 ms
4,368 KB
testcase_36 AC 2 ms
4,368 KB
testcase_37 AC 4 ms
4,368 KB
testcase_38 AC 18 ms
4,368 KB
testcase_39 AC 3 ms
4,368 KB
testcase_40 AC 1 ms
4,368 KB
testcase_41 AC 13 ms
4,368 KB
testcase_42 AC 1 ms
4,368 KB
testcase_43 AC 2 ms
4,368 KB
testcase_44 AC 19 ms
4,368 KB
testcase_45 AC 7 ms
4,368 KB
testcase_46 AC 1 ms
4,368 KB
testcase_47 AC 1 ms
4,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// yuki 1633 Sorting Integers (Multiple of 2^K)
// 2021.8.10

#include <stdio.h>
typedef long long ll;

int N;
int f[10];
int ans;

void rec(int a, int p2, ll p5, int w) {
	int i;
//printf("a=%d, p2=%d, w=%d\n", a, p2, w);
	if (p2 > ans) ans = p2;
	if (w == N) {
		while (!(a & 1)) p2++, a >>= 1;
		if (p2 > ans) ans = p2;
		return;
	}
	for (i = 1; i <= 9; ++i) if (f[i] && !((a+i*p5) & 1)) {
		f[i]--, rec((a+i*p5)>>1, p2+1, 5*p5, w+1), f[i]++;
	}
}

int main() {
	int i;

	scanf("%d", &N);
	for (i = 1; i <= 9; ++i) scanf("%d", f+i);
	for (i = 2; i < 10; i+=2) if (f[i]) {
		f[i]--, rec(i>>1, 1, 5, 1),f[i]++;
	}
	printf("%d\n", ans);
	return 0;
}
0