-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path101102B.cpp
More file actions
57 lines (50 loc) · 812 Bytes
/
101102B.cpp
File metadata and controls
57 lines (50 loc) · 812 Bytes
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
49
50
51
52
53
54
55
56
57
#include <bits/stdc++.h>
using namespace std;
map <int,int> f;
bool solve(int target, int length_rem)
{
if(target>=0&&length_rem>=0&&2*length_rem<=target&&7*length_rem>=target)
return true;
return false;
}
int main() {
int t;
scanf("%d",&t);
f[0] = 6;
f[1] = 2;
f[2] = 5;
f[3] = 5;
f[4] = 4;
f[5] = 5;
f[6] = 6;
f[7] = 3;
f[8] = 7;
f[9] = 6;
while(t--)
{
int n;
scanf("%d ",&n);
char x;
int sum = 0;
for(int i = 1; i<=n; i++)
{
scanf("%c",&x);
sum+=f[x-48];
}
//cout<<sum<<" "<<n<<endl;
for(int i = 1; i<=n; i++)
{
for(int j = 9; j>=0; j--)
{
if(solve(sum-f[j],n-i))
{
printf("%d",j);
sum = sum - f[j];
break;
}
}
}
printf("\n");
}
return 0;
}