Skip to content

Instantly share code, notes, and snippets.

@gorlum0
Created August 30, 2011 06:38
Show Gist options
  • Save gorlum0/1180332 to your computer and use it in GitHub Desktop.
Save gorlum0/1180332 to your computer and use it in GitHub Desktop.
codeforces - 110 - C (py)
#!/usr/bin/env python2.6
"""(c) gorlum0 [at] gmail.com"""
from sys import stdin
MAXN = 10**6
dp = [0] * (MAXN+1)
dp[0] = 1
for i in xrange(MAXN+1):
if dp[i-7]:
dp[i] = 7
elif dp[i-4]:
dp[i] = 4
for n in map(int, stdin):
if not dp[n]:
print -1; continue
lucky = []
while n:
lucky.append(dp[n])
n -= dp[n]
lucky.reverse()
print ''.join(map(str, lucky))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment