Problem 3053 --Rikka with Mista

3053: Rikka with Mista

"
Time Limit $6$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $12$ 正确数量 $1$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签
Rikka is a fervent fan of JoJo's Bizarre Adventure. As the last episode of Golden Wind has been aired, Rikka, with the help of Yuta, sets up this problem to express the love to Mista.

Mista's lucky number is 4. Today, Mista wants to test his luck with n magic cards: For each card, there is a non-negative integer on each side. The two numbers on the ith card are wi and 0.

Firstly, Mista puts these n cards to table one by one. For each card, the probability of the wi side to be upward is 12, and these probabilities are independent with each other. As a result, there are n integers on the table. Mista then sums up all these integers and counts the number of 4s in the decimal representation of this sum: He uses this result to measure his luckiness.

Since it's possible for each side of each card to be upward, there are 2n possible states in total. You are required to calculate the sum of the results for all these situations.
The first line of the input contains a single integer T(4≤T≤4), the number of test cases.

For each test case, the first line contains a single integer n(4≤n≤40), the number of the cards.

The second line contains n integers w1,…,wn(4≤wi≤44444444), the positive numbers on the cards.
For each test case, output a single line with a single integer, the answer.
4
4
4 4 4 4
4
4 4 44 44
4
4 44 44 4444
4
444 44444 44444 4444444
4
10
24
38

推荐代码 查看3053 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$5008 $ms] intLSY 500474 2019-10-20 16:45:33
内存最少[$25668 $KB] intLSY 500474 2019-10-20 16:45:33
第一AC intLSY 500474 2019-10-20 16:45:33
第一挑战 intLSY 500411 2019-10-20 16:04:25

赛题来源/所属竞赛 2019 Multi-University Training Contest 9 N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛