Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given a positive number N1=2579413, define a sub-integer of an integer to be composed of numbers that appear in the original integer, which can be

Given a positive number N1=2579413, define a sub-integer of an integer to be composed of numbers that appear in the original integer, which can be discontinuous but must maintain the order between the numbers. For example, 2, 5, 7, 9, 4, 1, 3, 25, 27, 29, 24, 293, 413, 2793, 57941, 2579413, etc. (not exhaustively listed) are all sub-integers of N1. The common sub-integer problem is given two integers N1, N2, the sub-integer that appears in each integer is the common sub-integer of N1 and N2.

For example, if N1=2579413, N2=354573, the common sub-integers are 5, 4, 3, 7, 57, 54, 53, 73, 43, 543, 573 and so on. The largest common sub-integer is defined as the largest common sub-integer (Largest Common Sub-Integer, LCSI) of these two integers". So N1=2579413, N2=354573, LCSI(N1, N2)=573.

Design a program (Python) that inputs two positive integers and outputs the largest common sub-integer of the two positive integers, or outputs 0 if there is none.

Enter a description: The input data of each test case is on the same line, represented as two positive integers N1, N2 separated by spaces.

The maximum number of digits for a single input integer is 50 digits.

Output description: Each set of test cases outputs one line, and the output is an integer.

Example input 1: 1357904 20468

Example output 1: 4

Example input 2: 2579413 354573

Example output 2: 573

Example input 3: 12365402345 316524015331

Example output 3: 365405

Example input 4: 123654045 31654015

Example output 4: 365405

Example input 5: 10579413 015143

Example output 5: 1543

Example input 6: 123654045123654045 3165401531654015

Example output 6: 365405365405

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Moving Objects Databases

Authors: Ralf Hartmut Güting, Markus Schneider

1st Edition

0120887991, 978-0120887996

More Books

Students also viewed these Databases questions