ExtraordinarilyLarge
SRM 320 · 2006-09-30 · by brett1479
Problem Statement
You need to handle two extraordinarily large integers. The good news is that you don't need to perform any arithmetic operation on them. You just need to compare them and see whether they are equal or one is greater than the other.
Given two
Notes
- In case you don't know about factorials, here is a quick definition: 0! is defined as 1. For any positive integer n, n! is defined as n * [(n-1)!]. For example, 5! = 5 * 4 * 3 * 2 * 1 * 0! = 120.
Constraints
- x and y will each contain between 1 and 50 characters, inclusive.
- x and y will each consist of a non-negative integer less than 109, with no extra leading zeros, followed by zero or more '!' characters.
"0!" "1" Returns: "x=y"
"9!" "999999999" Returns: "x
"9!!" "999999999" Returns: "x>y"
"456!!!" "123!!!!!!" Returns: "x
"5!" "120" Returns: "x=y"
Submissions are judged against all 164 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class ExtraordinarilyLarge with a public method string compare(string x, string y) · 164 test cases · 2 s / 256 MB per case