这代码令我瑟瑟发抖
by _StarDust @ 2019-04-26 10:30:39
@[WNLJOKER](/space/show?uid=179501) 大概是 input() 的时候读入了一些不可见字符,判掉就好了 QwQ
```py
# the map (char -> int) 'A':1 , 'B':2 etc.
dict_map = {}
for i in range (1,27):
dict_map[chr(64+i)] = i
FOURTY_SEVEN = 47
# get the name
comet_name = input()
team_name = input()
# culculate the product of name
comet_name_product = 1
for this_num in comet_name:
if this_num < 'A' or this_num > 'Z':
continue
#print(this_num)
comet_name_product *= dict_map[this_num]
team_name_product = 1
for this_num in team_name:
if this_num < 'A' or this_num > 'Z':
continue
#print(this_num)
team_name_product *= dict_map[this_num]
# check the name are fit or not
if (comet_name_product % FOURTY_SEVEN) == (team_name_product % FOURTY_SEVEN):
print('GO')
else :
print('STAY')
```
by 龙之吻—水货 @ 2019-04-26 10:56:26
@[龙之吻—水货](/space/show?uid=49866)
好的大佬,我试试
by WNLJOKER @ 2019-04-26 10:58:20
@[陌笙丶](/space/show?uid=98193) 是太啰嗦了吗
by WNLJOKER @ 2019-04-26 10:58:31
@[WNLJOKER](/space/show?uid=179501) 不,是我看不懂,我学的C++
by _StarDust @ 2019-04-26 11:00:10
@[龙之吻—水货](/space/show?uid=49866) 让我奇怪的是,题目说了彗星和团队的名字只有大写字母。。emmm
by WNLJOKER @ 2019-04-26 11:00:26
@[WNLJOKER](/space/show?uid=179501) 不是因为有其他字母,似乎是因为 `input()` 读入了 '\r', '\n' 之类的东西
by 龙之吻—水货 @ 2019-04-26 11:03:24
@[龙之吻—水货](/space/show?uid=49866) 这样啊。。换行符不是作为终止输入的标志,不会的读入的吗、。。
by WNLJOKER @ 2019-04-26 11:04:02
@[WNLJOKER](/space/show?uid=179501) 但实际上 input() 真的把换行符读进来了 QAQ
by 龙之吻—水货 @ 2019-04-26 11:08:34
@[龙之吻—水货](/space/show?uid=49866) 好的,谢谢大佬,以后input之后第一件事干掉\n
by WNLJOKER @ 2019-04-26 11:09:11