# google-code-jam 2019 Qualification Round Cryptopangrams

Cryptopangrams

int T, L;

array<int,L> arr

string S;

T组测试用例,每组测试用例给出arr,

arr由另一个字符串S变换而成

S满足:

1. 元素是[A-Z]26个大写字母, 每个字母至少出现一次
2. S的长度是L+1

eg. f={'A':2,'B':89,...}

L= [f[S[i]]*f[S[i+1]] for i in range(L)]

L N

arr

S

 import math from string import ascii_uppercase as upper T=int(input()) for t in range(1,1+T): N,L=map(int,input().split()) cipher=list(map(int,input().split()))     ori=[0]*(L+1)     for ent in range(L): r=int(math.sqrt(cipher[ent])) if r**2==cipher[ent]: ori[ent+1]=r break if ent!=L-1: g=math.gcd(cipher[ent],cipher[ent+1]) if g!=cipher[ent]: ori[ent+1]=g break # [0,0,<<< ✓ >>>,0,0] for j in range(ent,0 -1,-1): ori[j]=cipher[j]//ori[j+1] for j in range(ent+2,L +1): ori[j]=cipher[j-1]//ori[j-1]     # print(ori) psd=sorted(set(ori))     trans={psd[i]: upper[i] for i in range(len(psd))} for i in range(L+1): ori[i]=trans[ori[i]]     print("Case #{}: ".format(t)+"".join(ori))

 4 103 31 217 1891 4819 2291 2987 3811 1739 2491 4717 445 65 1079 8383 5353 901 187 649 1003 697 3239 7663 291 123 779 1007 3551 1943 2117 1679 989 3053 10000 33 3892729 3892729 3892729 3892729 3892729 3892729 3892729 3892729 175597 18779 50429 375469 1651121 2102 3722 2376497 611683 489059 2328901 3150061 829981 421301 76409 38477 291931 730241 959821 1664197 3057407 4267589 4729181 5335543 4023959 10000 28 175597 175597 175597 175597 416303 50429 375469 1651121 2102 3722 2376497 611683 489059 2328901 3150061 829981 421301 76409 38477 291931 730241 959821 1664197 3057407 4267589 4729181 5335543 4023959 10000 29 175597 175597 175597 175597 175597 18779 50429 375469 1651121 2102 3722 2376497 611683 489059 2328901 3150061 829981 421301 76409 38477 291931 730241 959821 1664197 3057407 4267589 4729181 5335543 4023959 Case #1: CJQUIZKNOWBEVYOFDPFLUXALGORITHMS Case #2: UUUUUUUUUBDERMATOGLYPHICFJKNQVWXZS Case #3: UBUBUDERMATOGLYPHICFJKNQVWXZS Case #4: UBUBUBDERMATOGLYPHICFJKNQVWXZS

posted @ 2019-04-09 09:38  migeater  阅读(...)  评论(...编辑  收藏