You Are Given a Decimal String...(CodeForces - 1202B)

题目

Suppose you have a special x-y-counter. This counter can store some value as a decimal number; at first, the counter has value 0.

The counter performs the following algorithm: it prints its lowest digit and, after that, adds either x or y to its value. So all sequences this counter generates are starting from 0. For example, a 4-2-counter can act as follows:

  1. it prints 0, and adds 4 to its value, so the current value is 4, and the output is 0;
  2. it prints 4, and adds 4 to its value, so the current value is 8, and the output is 04;
  3. it prints 8, and adds 4 to its value, so the current value is 12, and the output is 048;
  4. it prints 2, and adds 2 to its value, so the current value is 14, and the output is 0482;
  5. it prints 4, and adds 4 to its value, so the current value is 18, and the output is 04824.

This is only one of the possible outputs; for example, the same counter could generate 0246802468024 as the output, if we chose to add 2 during each step.

You wrote down a printed sequence from one of such x-y-counters. But the sequence was corrupted and several elements from the sequence could be erased.

Now you’d like to recover data you’ve lost, but you don’t even know the type of the counter you used. You have a decimal string s — the remaining data of the sequence.

For all 0≤x,y<10, calculate the minimum number of digits you have to insert in the string s to make it a possible output of the x-y-counter. Note that you can’t change the order of digits in string s or erase any of them; only insertions areallowed.

Input
The first line contains a single string s (1≤|s|≤2⋅10^6, si∈{0−9}) — the remaining data you have. It’s guaranteed that s1=0.

Output
Print a 10×10 matrix, where the j-th integer (0-indexed) on the i-th line (0-indexed too) is equal to the minimum number of digits you have to insert in the string s to make it a possible output of the i-j-counter, or −1 if there is no way to do so.

翻译一下下啦:╮(╯▽╰)╭

假设你有一个特殊的x-y计数器。该计数器可以存储一些十进制数值;首先,计数器的值为0。

计数器执行以​​下算法:它打印其最低位,然后在其值中添加x或y。因此,此计数器生成的所有序列都从0开始。例如,4-2计数器可以如下操作:

1.打印0,并将其值加4,所以当前值为4,输出为0;
2.打印4,并将其值加4,所以当前值为8,输出为04;
3.打印8,并将其值加4,所以当前值为12,输出为048;
4.打印2,并将其值加2,所以当前值为14,输出为0482;
5.它打印4,并将其值加4,因此当前值为18,输出为04824。

这只是可能的产出之一;例如,如果我们选择在每个步骤中添加2,则同一计数器可以生成0246802468024作为输出。

您从其中一个x-y计数器中记下了打印序列。但是序列被破坏了,序列中的几个元素可以被删除。

现在您想要恢复丢失的数据,但您甚至不知道您使用的计数器的类型。你有一个十进制字符串s - 序列的剩余数据。

对于所有0≤x,y <10,计算必须在字符串s中插入的最小位数ÿ

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值