TopcoderArchiveVisit Topcoder
TCO18 Sep 2018
TCO19 SRM 737

Make737Hard

Problem statement, definition, constraints, and public examples.

Problem Statement

Given a string S, a 737-triple in S is a triple (i,j,k) such that:

  • i, j, k are valid indices into S such that i < j < k
  • S[i] = '7', S[j] = '3', and S[k] = '7'.

You are given an int X. Your task is to generate and return any string S such that:

  • The length of S is between 1 and 373, inclusive.
  • The string S contains only characters '3' and '7'.
  • The number of 737-triples in S is exactly X.

You may assume that for the given constraints a solution always exists.

Definition

Class:
Make737Hard
Method:
make
Parameters:
int
Returns:
String
Method signature:
String make(int X)
(be sure your method is public)

Constraints

  • X will be between 0 and 1,737,373, inclusive.

Examples

  1. 1
    Returns: "737"
  2. 8
    Returns: "773377"
  3. 0
    Returns: "777333"
  4. 4
    Returns: "73737"
Back to all problems