-
Notifications
You must be signed in to change notification settings - Fork 0
/
SCTDL047.cpp
48 lines (48 loc) · 1.01 KB
/
SCTDL047.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* @file SCTDL047.cpp
* @author Long ([email protected])
* @brief Lucky number is a number that includes digits 4 & 7.
* The author want to find the smallest lucky number that has
* sum of all its digits equal to N
* @version 0.1
* @date 2023-06-10
*
* @copyright Copyright (c) 2023
*
*/
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--)
{
int n, ok = 0;
cin >> n;
for (int i = 0; i <= n / 4; i++)
{
if ((n - i * 4) % 7 == 0)
{
ok = 1;
for (int j = 0; j < i; j++)
{
cout << 4;
}
for (int j = 0; j < (n - i * 4) / 7; j++)
{
cout << 7;
}
cout << endl;
break;
}
}
if (ok == 0)
{
cout << -1 << endl;
}
}
}