Connection Status:
Competition Arena > SeventhPowers
TCO19 SRM 754 · 2019-03-25 · by misof · Brute Force, Greedy, Simple Math
Class Name: SeventhPowers
Return Type: String
Method Name: reconstructA
Arg Types: (int)
Problem Statement

Problem Statement

Alice had some positive integer A with at most 500 digits. Bob looked at A and computed the number B: the sum of seventh powers of digits of A.

For example, if Alice had the number A = 407, Bob computed the number B = 4^7 + 0^7 + 7^7 = 839927.

You are given the number B. Find and return a String containing the decimal representation of any valid number A.

Notes

  • The answer always exists.
  • Any valid answer will be accepted. (Remember that A must have at most 500 digits.)
  • The String you return cannot have leading zeros.

Constraints

  • B will be between 1 and 10,000,000, inclusive.
Examples
0)
839927
Returns: "407"
1)
130
Returns: "121"
2)
43740
Returns: "33333333333333333333"

20 * 3^7 = 43,740.

3)
8484235
Returns: "987665544433333322222222222222221111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
4)
127
Returns: "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"

Submissions are judged against all 62 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class SeventhPowers with a public method string reconstructA(int B) · 62 test cases · 2 s / 256 MB per case

Submitting as anonymous