Maximum Number (Codeforces 795C)
Tags: Greedy, *special

Stepan has the newest electronic device with a display. Different digits can be shown on it. Each digit is shown on a seven-section indicator like it is shown on the picture below.  So, for example, to show the digit 3 on the display, 5 sections must be highlighted; and for the digit 6, 6 sections must be highlighted. The battery of the newest device allows to highlight at most n sections on the display. Stepan wants to know the maximum possible integer number which can be shown on the display of his newest device. Your task is to determine this number. Note that this number must not contain leading zeros. Assume that the size of the display is enough to show any integer.

Input: The first line contains the integer n (2 ≤ n ≤ 100 000) — the maximum number of sections which can be highlighted on the display.

Output: Print the maximum integer which can be shown on the display of Stepan's newest device.


Sample Inputs:
2

3

Sample Outputs:
1

7

Solution (Python):
from sys import stdin, stdout
(input, print) = (stdin.readline, stdout.write)
n = int(input())
if n % 2 == 0:
    print('1' * (n // 2) + '\n')
else:
    print('7' + '1' * ((n - 3) // 2) + '\n')

Solution (Python):
n = int(input())
if n % 2 == 0:
    print('1' * (n // 2))
else:
    print('7' + '1' * (n // 2 - 1))

Solution (Python):
n = int(input())
g = ''
while n >= 2:
    if n / 2 == 1 and n % 2 == 1:
        g += '7'
        n = n - 3
    elif (n - 3) % 2 == 0:
        g += '7'
        n = n - 3
    elif n >= 2:
        g += '1'
        n = n - 2
print(g)