Transformation
SRM 391 · 2008-02-26 · by stone
Problem Statement
You are to transform a positive integer vector (A1,A2,...,An)
into another positive integer vector (B1,B2,...,Bn) of the same length.
The transformation must satisfy the conditions below:
1) For 1 < = i < =n., Bi must evenly divide into Ai.
2) The least common multiple of all Ai should be equal to that of all Bi.
You are given the original integer vector as a
Notes
- The least common multiple of a group of positive integers is the least positive integer which is a multiple of every integer in the group.
Constraints
- A will contain between 1 and 50 elements, inclusive.
- Each element of A will contain digits ('0' - '9') only.
- Each element of A will represent a positive integer without leading zeros.
- Each element of A will contain between 1 and 18 characters, inclusive.
{"1","2"}
Returns: {"1", "2" }
{"2","2"}
Returns: {"1", "2" }
{"1","3","6"}
Returns: {"1", "1", "6" }
{"2","3","6"}
Returns: {"1", "1", "6" }
{1,1,6},{1,3,2},{1,3,6},{2,1,3},{2,1,6},{2,3,1},{2,3,2},{2,3,3},{2,3,6} are all transformation results.
{"210","2","3","5","7"}
Returns: {"1", "2", "3", "5", "7" }
Submissions are judged against all 143 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class Transformation with a public method vector<string> transform(vector<string> A) · 143 test cases · 2 s / 256 MB per case