7678

JimmyHu

niumaa

Mr.Lonely
R星_魔鬼训练ing
RandyLuo
Ethereum
Tequila

zdkk
abcdeab

lst=list(map(int,input().split()))
dic={i:str(i) for i in range(10)}
dic[10]="A"
dic[11]="B"
dic[12]="C"
def get(x):
if x<13:
res="0"+dic[x]
else:
res=dic[x//13]+dic[x%13]
return res
ans="#"
for i in lst:
ans+=get(i)
print(ans)



def is_prime(x):
if x==1:
return False
i=2
while i*i<=x:
if x%i==0:
return False
i+=1
return True
def rev(x,d):
ans=0
while x:
ans=ans*d+x%d
x//=d
return ans
while True:
try:
a,b=map(int,input().split())
if is_prime(a)  and is_prime(rev(a,b)):
print("Yes")
else:
print("No")
except:
break


a,b,tag,radix=input().split()
mapping = {str(i): i for i in range(10)}
mapping.update({chr(i): i-ord("a")+10 for i in range(ord("a"), ord("z")+1)})

if tag=='2':
a,b=b,a
def get(n,r):
ans=0
idx=1
for i in range(1,len(n)+1):
ans+=mapping[n[-i]]*idx
idx*=r
return ans
l=mapping[max(list(b))]
r=max(target,36)
while l<r:
mid=(l+r)>>1
if get(b,mid)>=target:
r=mid
else:
l=mid+1
if get(b,1)==target and len(b)==1:
print(int(b)+1)
elif get(b,r)==target:
print(r)
else:
print("Impossible")


t=int(input())
for i in range(1,t+1):
n=int(input())
arr=list(map(int,input().split()))+[float("inf")]
ans=2
left=0
right=2
while right<=n:
if arr[right]-arr[right-1]!=arr[left+1]-arr[left]:
ans=max(ans,right-left)
left=right-1
right+=1
print("Case #{}: {}".format(i,ans))


### 题目描述

blablabla

python非递归写法（递归爆栈）

from collections import deque
m,n=map(int,input().split())
order=list(map(int,input().split()))
pre=list(map(int,input().split()))

dic={}
q=deque([[0,n-1,0,n-1,0,float("inf")]])
while q:
pl,pr,dl,dr,d,f=q.popleft()
root=pre[pl]
dic[root]=[f,d]
k=order.index(root)
if dl<k:
q.append([pl+1,pl+1+(k-1-dl),dl,k-1,d+1,root])
if k<dr:
q.append([pl+1+(k-1-dl)+1,pr,k+1,dr,d+1,root])

for _ in range(m):
a,b=map(int,input().split())
if a not in dic and b not in dic:
elif a not in dic:
elif b not in dic:
else:
fa=a
fb=b
da=dic[a][1]
db=dic[b][1]
while fa!=fb:
if da<db:
fb=dic[fb][0]
db-=1
else:
fa=dic[fa][0]
da-=1
if fa==a:
print("{} is an ancestor of {}.".format(a,b))
elif fa==b:
print("{} is an ancestor of {}.".format(b,a))
else:
print("LCA of {} and {} is {}.".format(a,b,fa))


from collections import deque
m,n=map(int,input().split())
order=list(map(int,input().split()))
pre=list(map(int,input().split()))

dic={}
q=deque([[0,n-1,0,n-1,0,float("inf")]])
while q:
pl,pr,dl,dr,d,f=q.popleft()
root=pre[pl]
dic[root]=[f,d]
k=order.index(root)
if dl<k:
q.append([pl+1,pl+1+(k-1-dl),dl,k-1,d+1,root])
if k<dr:
q.append([pl+1+(k-1-dl)+1,pr,k+1,dr,d+1,root])

for _ in range(m):
a,b=map(int,input().split())
if a not in dic and b not in dic:
elif a not in dic:
elif b not in dic:
else:
fa=a
fb=b
da=dic[a][1]
db=dic[b][1]
while fa!=fb:
if da<db:
fb=dic[fb][0]
db-=1
else:
fa=dic[fa][0]
da-=1
if fa==a:
print("{} is an ancestor of {}.".format(a,b))
elif fa==b:
print("{} is an ancestor of {}.".format(b,a))
else:
print("LCA of {} and {} is {}.".format(a,b,fa))


from collections import deque
m,n=map(int,input().split())
pre=list(map(int,input().split()))
order=sorted(pre)
dic={}
q=deque([[0,n-1,0,n-1,0,float("inf")]])
while q:
pl,pr,dl,dr,d,f=q.popleft()
root=pre[pl]
dic[root]=[f,d]
k=order.index(root)
if dl<k:
q.append([pl+1,pl+1+(k-1-dl),dl,k-1,d+1,root])
if k<dr:
q.append([pl+1+(k-1-dl)+1,pr,k+1,dr,d+1,root])

for _ in range(m):
a,b=map(int,input().split())
if a not in dic and b not in dic:
elif a not in dic:
elif b not in dic:
else:
fa=a
fb=b
da=dic[a][1]
db=dic[b][1]
while fa!=fb:
if da<db:
fb=dic[fb][0]
db-=1
else:
fa=dic[fa][0]
da-=1
if fa==a:
print("{} is an ancestor of {}.".format(a,b))
elif fa==b:
print("{} is an ancestor of {}.".format(b,a))
else:
print("LCA of {} and {} is {}.".format(a,b,fa))


from collections import deque
t=int(input())
for i in range(1,t+1):
while True:
s=input()
if s:
s=int(s)
break
arr=[]
for _ in range(s):
arr.append(list(map(int,input().split())))
ans=1
idx=1
for x in range(s):
for y in range(s):
q=deque([[arr[x][y],x,y]])
t=0
while q:
t+=1
v,a,b=q.popleft()
for nx,ny in [(a-1,b),(a+1,b),(a,b-1),(a,b+1)]:
if nx>=0 and nx<s and ny>=0 and ny<s and arr[nx][ny]==v+1:
q.append([v+1,nx,ny])
if t>ans:
idx=arr[x][y]
ans=t
elif t==ans and idx>arr[x][y]:
idx=arr[x][y]
print("Case #{}: {} {}".format(i,idx,ans))


n=int(input())
pre=list(map(int,input().split()))
order=list(map(int,input().split()))

pl=0
pr=n-1
il=0
ir=n-1
while il<ir:
root=pre[pl]
k=order.index(root)
if k>il:
pl=pl+1
pr=k-il+pl
ir=k-1
else:
pl=k-il+pl+1
il=k+1
print(order[ir])


n=int(input())
pre=list(map(int,input().split()))
order=list(map(int,input().split()))

pl=0
pr=n-1
il=0
ir=n-1
while il<ir:
root=pre[pl]
k=order.index(root)
if k>il:
pl=pl+1
pr=k-il+pl
ir=k-1
else:
pl=k-il+pl+1
il=k+1
print(order[ir])