CF1250H.Happy Birthday

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You have a set of birthday cake candles. Each of such candles represents a digit between 00 and 99, inclusive.

Example of birthday cake candles.

Let's denote the candle representing the digit dd as dd-candle.

Your set contains c0c_0 instances of 00-candles, c1c_1 instances of 11-candles and so on. So, the total number of candles is c0+c1+⋯+c9c_0+c_1+\dots+c_9.

These digits are needed to wish your cat a happy birthday. For each birthday, starting with the first, you want to compose the age of the cat using the digits from the set.

Since you light candles for a very short time, candles don't have time to burn out. For this reason you can reuse candles an arbitrary number of times (therefore your set of candles never changes).

For example, if you have one instance of each digit (i.e. c0=c1=⋯=c9=1c_0=c_1=\dots=c_9=1), you can compose any number from 11 to 1010 using this set, but you cannot compose 1111.

You have to determine the first birthday, on which you cannot compose the age of the cat using the candles from your set. In other words, find the minimum number yy such that all numbers from 11 to y−1y-1 can be composed by digits from your set, but yy cannot be composed.

你有一组生日蛋糕蜡烛。每根这样的蜡烛代表一个介于 00 到 99(含)之间的数字。

生日蛋糕蜡烛示例。

我们用 dd-蜡烛表示代表数字 dd 的蜡烛。

你的蜡烛集合中包含 c0c_0 根 00-蜡烛、c1c_1 根 11-蜡烛,依此类推。因此,蜡烛总数为 c0+c1+⋯+c9c_0+c_1+\dots+c_9。

这些数字用于为你家猫咪庆祝生日。从第一个生日开始,每次生日你都希望用集合中的数字拼出猫咪的年龄。

由于你点燃蜡烛的时间极短,蜡烛不会烧毁。因此,你可以无限次重复使用任意一根蜡烛(即你的蜡烛集合始终保持不变)。

例如,若你每种数字各有一根蜡烛(即 c0=c1=⋯=c9=1c_0=c_1=\dots=c_9=1),则可用该集合拼出 11 至 1010 之间的任意数字,但无法拼出 1111。

你需要确定第一个无法用你现有蜡烛集合拼出猫咪年龄的生日。换言之,找出最小的正整数 yy,使得所有从 11 到 y−1y-1 的数字均能由你集合中的数字拼出,但 yy 无法拼出。

输入格式

The first line contains an integer tt (1≤t≤1041 \le t \le 10^4) — the number of test cases in the input.

The only line of each test case contains ten integer numbers c0,c1,…,c9c_0, c_1, \dots, c_9 (0≤ci≤1050 \le c_i \le 10^5) — the number of 00-candles, 11-candles, 22-candles and so on.

It is guaranteed that the sum of all cic_i in the input does not exceed 10610^6.

第一行包含一个整数 tt(1≤t≤1041 \le t \le 10^4)—— 表示输入中测试用例的数量。

每个测试用例仅一行,包含十个整数 c0,c1,…,c9c_0, c_1, \dots, c_9(0≤ci≤1050 \le c_i \le 10^5)—— 分别表示数字 00 的蜡烛、数字 11 的蜡烛、数字 22 的蜡烛,依此类推的数量。

保证输入中所有 cic_i 的总和不超过 10610^6。

输出格式

For each test case, output one integer in single line — the minimum age which cannot be composed by candles from your set. Please note that the age can be quite large (it may exceed the standard 64-bit integer types in your programming language).

对于每个测试用例,在单独一行中输出一个整数——即无法用你所拥有的蜡烛组合出的最小年龄。请注意,该年龄可能非常大(可能超出编程语言中标准的 64 位整数类型范围)。

输入输出样例

  • 输入#1

    4
    1 1 1 1 1 1 1 1 1 1
    0 0 1 1 2 2 3 3 4 4
    1 2 1 2 1 3 1 0 0 0
    0 1 2 1 4 3 1 1 2 1

    输出#1

    11
    1
    7
    10

输入解题思路,AI测评打分。不知道怎么写?

首页