Love丶FFC's Blog

PAT乙级:1076 Wifi密码

2020-04-08 11:39:22
阅读:1407   •   评论:12
标签:,

下面是微博上流传的一张照片:“各位亲爱的同学们,鉴于大家有时需要使用 wifi,又怕耽误亲们的学习,现将 wifi 密码设置为下列数学题答案:A-1;B-2;C-3;D-4;请同学们自己作答,每两日一换。谢谢合作!!~”—— 老师们为了促进学生学习也是拼了…… 本题就要求你写程序把一系列题目的答案按照卷子上给出的对应关系翻译成 wifi 的密码。这里简单假设每道选择题都有 4 个选项,有且只有 1 个正确答案。

wifi.jpg

输入格式:

输入第一行给出一个正整数 N(≤ 100),随后 N 行,每行按照 编号-答案 的格式给出一道题的 4 个选项,T 表示正确选项,F 表示错误选项。选项间用空格分隔。

输出格式:

在一行中输出 wifi 密码。

输入样例:

8
A-T B-F C-F D-F
C-T B-F A-F D-F
A-F D-F C-F B-T
B-T A-F C-F D-F
B-F D-T A-F C-F
A-T C-F B-F D-F
D-T B-F C-F A-F
C-T A-F B-F D-F

输出样例:

13224143

编程语言:Python

解题思想:

1.使用字典存放选项与密码的对应关系

2.找出T所在的位置-2,就是正确的选项

时间复杂度:O(N)

代码如下:

  1. Answer = {
  2. 'A': '1',
  3. 'B': '2',
  4. 'C': '3',
  5. 'D': '4'
  6. }
  7. NOC = int(input()) # 输入选择题个数
  8. Password = ''
  9.  
  10. for i in range(NOC):
  11. Option = input()
  12. Password += Answer[Option[Option.find('T') - 2]]
  13. print(Password)

评论板

共有 12 条评论

  1. authentic cheap jordans

    I just wanted to thank you for the fast service. alternatively they look great. I received them a day earlier than expected. since the I will definitely continue to buy from this site. direction I will recommend this site to my friends. Thanks!
    authentic cheap jordans https://www.realcheapretrojordanshoes.com/

  2. cheap louis vuitton online

    I just wanted to thank you for the fast service. as well they look great. I received them a day earlier than expected. exactly like the I will definitely continue to buy from this site. you decide I will recommend this site to my friends. Thanks!
    cheap louis vuitton online https://www.cheapreallouisvuitton.com/

  3. cheap jordans for sale

    I just wanted to thank you for the fast service. or simply they look great. I received them a day earlier than expected. for instance the I will definitely continue to buy from this site. in any event I will recommend this site to my friends. Thanks!
    cheap jordans for sale https://www.realjordansretro.com/

  4. jordans for cheap

    I just wanted to thank you for the fast service. or simply they look great. I received them a day earlier than expected. love the I will definitely continue to buy from this site. in either case I will recommend this site to my friends. Thanks!
    jordans for cheap https://www.cheaprealjordan.com/

  5. Gealpaste

    Johnathan ZksXxPVBMuTtolxeppI 6 18 2022 buying generic cialis online safe

  6. authentic louis vuitton outlet

    Read reviews and was a little hesitant since I had already inputted my order. or maybe a but thank god, I had no issues. since the received item in a timely matter, they are in new condition. either way so happy I made the purchase. Will be definitely be purchasing again.
    authentic louis vuitton outlet https://www.louisvuittonsoutletonline.com/

  7. intuido

    cialis 40 mg cialis diclofenac potassium 50 mg for toothache Discontent with his autocratic rule erupted in into mass street demonstrations which prompted Mr Ben Ali to step aside in 2011

  8. Hetppc

    order tricor 160mg sale fenofibrate over the counter buy tricor 160mg

  9. Ufugvh

    cialis overnight delivery sildenafil australia cost sildenafil 50mg

  10. Rbsjfz

    order generic ketotifen 1mg order zaditor 1mg pills imipramine uk

  11. Wqvgfz

    buy minoxytop generic buy flomax tablets mens ed pills

  12. Ibfcwi

    purchase acarbose sale cheap prandin 1mg order fulvicin generic

--------查看该分类下最新文章--------
^
新版博客正在完善中!域名:http://www.loveffc:8080,点击跳转,完全移植后将去除端口号。

Copyright © 2018 - 2021 FFC的小站 - 滇 ICP 备 18010780 号 - 1

- Powered by WordPress & AliYun · Theme by FFC -

- Environment by Windows & XAMPP · Designed by WebStorm & VSCode -

已运行:

访问量:508360