ural 1071. Nikifor 2

1071. Nikifor 2

Time limit: 1.0 second
Memory limit: 64 MB
Nikifor has a number  x. He doesn't need it. He needs a number  y. Nikifor tries to obtain the required number by erasing some digits from  x. But he is not lucky in the meanwhile. May be he is to choose an appropriate number system?
Write a program that reads numbers  x and  y, and determines a minimal radix of a number system that it is possible to obtain in it the number  y from  x by erasing some digits. If it is impossible, your program should write to an output a message "No solution".

Input

The only line contains integers  x and  y (1 ≤  y <  x ≤ 1 000 000), separated with a space.

Output

Output either the message "No solution", if there is no appropriate number system, or an integer, not less than 2, that is an answer in the problem.

Sample

inputoutput
127 16
3
Problem Author: Dmitry Filimonenkov
Problem Source: Ural State Univerisity Personal Contest Online February'2001 Students Session 
Tags: none   ( hide tags for unsolved problems )

转载于:https://www.cnblogs.com/StupidBoy/p/5076818.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值