码迷,mamicode.com
首页 > 其他好文 > 详细

ural 1071. Nikifor 2

时间:2015-12-25 20:54:59      阅读:217      评论:0      收藏:0      [点我收藏+]

标签:

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 

ural 1071. Nikifor 2

标签:

原文地址:http://www.cnblogs.com/StupidBoy/p/5076818.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!