Created
March 20, 2015 12:38
-
-
Save vishnujayvel/2acf7513c3e867eace73 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vector> | |
#include <list> | |
#include <map> | |
#include <set> | |
#include <deque> | |
#include <queue> | |
#include <stack> | |
#include <bitset> | |
#include <algorithm> | |
#include <functional> | |
#include <numeric> | |
#include <utility> | |
#include <sstream> | |
#include <iostream> | |
#include <iomanip> | |
#include <cstdio> | |
#include <cmath> | |
#include <cstdlib> | |
#include <ctime> | |
#include <cstring> | |
#include <climits> | |
#include <stdlib.h> | |
#include <stdio.h> | |
using namespace std; | |
#define REP(i,n) for(int i=0; i<n; i++) | |
#define FOR(i,st,end) for(int i=st;i<end;i++) | |
#define db(x) cout << (#x) << " = " << x << endl; | |
#define mp make_pair | |
#define pb push_back | |
#define MAX 10000005 | |
typedef long long int ll; | |
int main(){ | |
int n; | |
cin>>n; | |
if(n<4){ | |
cout<<"-1"; | |
return 0; | |
} | |
int numSeven=n/7; | |
int rem=n%7; | |
int numFour=rem/4; | |
int toBecomeFour=rem%4; | |
if(toBecomeFour!=0){ | |
if(numSeven>=toBecomeFour){ | |
numFour+=((7*toBecomeFour)+toBecomeFour)/4; | |
numSeven-=toBecomeFour; | |
} | |
else{ | |
cout<<"-1"; | |
return 0; | |
} | |
} | |
REP(i,numFour) | |
cout<<"4"; | |
REP(i,numSeven) | |
cout<<"7"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment