#3851. 2048

2048

题目描述

Teacher Mai is addicted to game 2048. But finally he finds it's too hard to get 2048. So he wants to change the rule: You are given some numbers. Every time you can choose two numbers of the same value from them and merge these two numbers into their sum. And these two numbers disappear meanwhile.

If we can get 2048 from a set of numbers with this operation, Teacher Mai think this multiset is good. You have nn numbers, A1,...,AnA_1,...,A_n. Teacher Mai ask you how many subsequences of AA are good. The number can be very large, just output the number mod\bmod 998244353998244353.

输入格式

There are multiple test cases, terminated by a line "0". For each test case, the first line contains an integer nn (1n105)(1 \le n \le 10^5), the next line contains nn integers aia_i (0ai2048)(0 \le ai \le 2048).

输出格式

For each test case, output one line "Case #k: ans", where kk is the case number counting from 11 , ans is the number mod\bmod 998244353998244353.

1024 512 256 256
4
1024 1024 1024 1024
5
1024 512 512 512 1
0
Case #2: 11
Case #3: 8

提示

In the first case, we should choose all the numbers. In the second case, all the subsequences which contain more than one number are good.