Love丶FFC's Blog

PAT乙级:1006 换个格式输出整数

2020-01-28 22:15:58
阅读:6929   •   评论:140
标签:,

让我们用字母 B 来表示“百”、字母 S 表示“十”,用 12...n 来表示不为零的个位数字 n(<10),换个格式来输出任一个不超过 3 位的正整数。例如 234 应该被输出为 BBSSS1234,因为它有 2 个“百”、3 个“十”、以及个位的 4。

输入格式:

每个测试输入包含 1 个测试用例,给出正整数 n(<1000)。

输出格式:

每个测试用例的输出占一行,用规定的格式输出 n

输入样例 1:

234

输出样例 1:

BBSSS1234

输入样例 2:

23

输出样例 2:

SS123

编程语言:Python

解题思想:

1.百位数字=Number//100

2.十位数字=Number%100//10

3.个位数字=Number%100%10

4.python字符串乘法以及//、/、%的区别

时间复杂度:O(n)

  1. Number = int(input())
  2. String = (Number // 100) * 'B' + (Number % 100) // 10 * 'S' # 百位、十位操作
  3. for i in range(1, Number % 100 % 10 + 1): # 个位操作
  4. String += str(i)
  5. print(String)

评论板

共有 140 条评论

  1. fruinly

    cialis coupons This matter comes before the Court upon Defendant Monty Turner s Motion for Release from Custody

  2. fruinly

    daily cialis online When analyzed according to P gp phenotype, CsA extended median survival 3 fold in patients with P gp leukemia 12 months versus 4 months with a corresponding increase in RFS 17 months versus 7 months, whereas no difference was observed in patients lacking P gp

  3. engarma

    and superior control over timing to buy cialis 20mg

  4. jordans for cheap

    Read reviews and was a little hesitant since I had already inputted my order. or to but thank god, I had no issues. choose the received item in a timely matter, they are in new condition. direction so happy I made the purchase. Will be definitely be purchasing again.
    jordans for cheap https://www.cheapsneakeronline.com/

  5. louis vuittons outlet

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

  6. jordans for cheap

    Read reviews and was a little hesitant since I had already inputted my order. in addition to but thank god, I had no issues. similar to received item in a timely matter, they are in new condition. anyway so happy I made the purchase. Will be definitely be purchasing again.
    jordans for cheap https://www.realjordansshoes.com/

  7. louis vuittons outlet

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

  8. Preliaf

    Palbociclib is metabolized primarily by CYP 3A4 enzymes; strong CYP 3A4 inhibitors or inducers are considered contraindications when used in combination with palbociclib buy cialis usa

  9. Preliaf

    WBC Count 4, 500 to 11, 000 cells mm Neutrophils 55 70 or 1, 800 to 7, 800 cells mm Lymphocytes 20 40 or 1, 000 to 4, 800 cells mm Monocytes 2 8 or 0 generic cialis vs cialis

  10. صناعة الأنابيب uPVC

    تشتهر تجهيزات HDPE من إيليت بايب Elite Pipe بتعدد استخداماتها ، مما يسمح بوصلات آمنة وفعالة في تطبيقات متنوعة مثل إمدادات المياه وتوزيع الغاز وخطوط الأنابيب الصناعية.

--------查看该分类下最新文章--------
^
新版博客正在完善中!域名: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 -

已运行:

访问量:451204