Codeforces and Polygon may be unavailable from December 6, 19:00 (UTC) to December 6, 21:00 (UTC) due to technical maintenance. ×

МЭ информатика C9

Revision ru1, by petr_qwerty, 2024-12-03 20:01:13

a=int(input()) d=[[0,8],[1,7,4,3,9,8],[2,8],[3,9,8],[4,9,8],[5,6,9,8],[6,8],[7,9,8],[8],[9]] e=[[0,1],[0,1,2,3,4,5],[0,2],[0,1,2],[0,2,3],[0,1,1,2],[0,1],[0,2,4],[0],[0]]

x=""

for i in range(a): b,c=map(int,input().split()) for i in range(len(str(b))): e[int(str(b)[i])].append(c+1) cm=d[int(str(b)[i])][0:e[int(str(b)[i])].index(c+1)] x+=str(max(cm)) c-=e[int(str(b[i]))][d[int(str(b[i]))].index(max(cm))] e[int(str(b[i]))].insert(c+1) print(x) x=""

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
ru1 Russian petr_qwerty 2024-12-03 20:01:13 546 Первая редакция (опубликовано)