Love丶FFC's Blog

PAT乙级:1011 A+B 和 C

2020-02-02 11:29:46
阅读:731   •   评论:8
标签:,

给定区间 [−2​31​​,2​31​​] 内的 3 个整数 AB 和 C,请判断 A+B 是否大于 C

输入格式:

输入第 1 行给出正整数 T (≤10),是测试用例的个数。随后给出 T 组测试用例,每组占一行,顺序给出 AB 和 C。整数间以空格分隔。

输出格式:

对每组测试用例,在一行中输出 Case #X: true 如果 A+B>C,否则输出 Case #X: false,其中 X 是测试用例的编号(从 1 开始)。

输入样例:

4
1 2 3
2 3 4
2147483647 0 2147483646
0 -2147483648 -2147483647

输出样例:

Case #1: false
Case #2: true
Case #3: true
Case #4: false

编程语言:Python

解题思想:

1.利用Python动态类型的特性

2.即时判断,输入一行判断一行

时间复杂度:O(n)

代码如下:

  1. NOJ = int(input())
  2. for i in range(NOJ):
  3. A, B, C = map(int, input().split())
  4. if A + B > C:
  5. print("Case #"+str(i+1)+": true")
  6. else:
  7. print("Case #" + str(i + 1) + ": false")

评论板

共有 8 条评论

  1. Jorcift

    cialis levitra comment viagra Entering these factors into multivariate analysis Table 3, RS fractionally ranked, both central G3 and local G3 v G1 or G2, and nodal status pN1 to 3 v pN0 and pN2 to 3 v pN1 to 2 were significant multivariate prognostic factors for DFS in this population

  2. cheap retro jordans

    I just wanted to thank you for the fast service. as well they look great. I received them a day earlier than expected. decline I will definitely continue to buy from this site. manner in which I will recommend this site to my friends. Thanks!
    cheap retro jordans https://www.cheaprealjordan.com/

  3. cheap retro jordans

    I just wanted to thank you for the fast service. as well they look great. I received them a day earlier than expected. most notably I will definitely continue to buy from this site. no matter what I will recommend this site to my friends. Thanks!
    cheap retro jordans https://www.realjordansretro.com/

  4. cheap louis vuitton bags

    Read reviews and was a little hesitant since I had already inputted my order. in addition but thank god, I had no issues. like the received item in a timely matter, they are in new condition. you ultimately choose so happy I made the purchase. Will be definitely be purchasing again.
    cheap louis vuitton bags https://www.louisvuittonsoutletstore.com/

  5. louis vuitton outlet online

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

  6. intuido

    generic propecia for sale Here, we demonstrated that SPEG loss results in hypophosphorylated JPH2, which is a novel mechanism underlying the disruption of TT

  7. intuido

    best price for generic levitra Data analysis and interpretation Jennifer M

  8. hQBeVoaMU

    22 for estrogen progesterone, 1 cialis no prescription

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

已运行:

访问量:511460