Skip to content

Instantly share code, notes, and snippets.

@Shravan40
Created September 21, 2013 18:31
Show Gist options
  • Save Shravan40/6652974 to your computer and use it in GitHub Desktop.
Save Shravan40/6652974 to your computer and use it in GitHub Desktop.
#include <cmath>
#include <cstdio>
#include <vector>
#include<string>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int temp = n%3;
n /= 3;
if(temp == 0)
{
while(n--)
{
cout<<"555";
}
}
else if(temp == 2)
{
if(n >= 1)
{
n -=1;
while(n--)
{
cout<<"555";
}
cout<<"33333";
}
else
{
cout<<"-1";
}
}
else
{
int flag = 0;
while(n--)
{
temp += 3;
if(temp % 5 == 0)
{
while(n--)
{
cout<<"555";
}
temp /= 5;
while(temp--)
{
cout<<"33333";
}
flag = 1;
}
if(flag == 1)
{
break;
}
}
if(flag == 0)
{
cout<<"-1";
}
}
cout<<"\n";
}
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment