题解 | #MP3光标位置#
MP3光标位置
http://www.nowcoder.com/practice/eaf5b886bd6645dd9cfb5406f3753e15
没通过全部用例
while True:
try:
a = int(input())
b = input()
pl = []
for i in range(a):
pl.append(i+1)
res =[]
def getnum(a):
j = 0
for i in b:
if i == 'U':
j = j - 1
if j%a != 0:
j=j%a
res.append(pl[j])
else:
j=0
res.append(pl[j])
if i == 'D':
j = j + 1
if j%a != 0:
j = j%a
res.append(pl[j])
else:
j = 0
res.append(pl[j])
return(res[-1])
if a<=4:
print(' '.join(map(str,pl)))
getnum(a)
print(res[-1])
else:
getnum(a)
if res[-1]+3<=a-1:
print(' '.join(map(str,pl[res[-1]-1:res[-1]+3])))
print(res[-1])
else:
print(' '.join(map(str,pl[-4:])))
print(res[-1])
#else:
#res = sorted(res)
#print(' '.join(map(str,res)))
#print(res[0])
except:
break