返回
Featured image of post 洛谷-入门1-顺序结构

洛谷-入门1-顺序结构

基础不牢啊

B2002 Hello, World!

Hello,World!

1
print(print("Hello,World!"))

B2025 输出字符菱形

输出字符菱形

1
2
3
4
5
print('  *')
print(' ***')
print('*****')
print(' ***')
print('  *')

P1000 超级玛丽游戏

超级玛丽游戏

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
scene = [
        "                ********",
        "               ************",
        "               ####....#.",
        "             #..###.....##....",
        "             ###.......######              ###            ###",
        "                ...........               #...#          #...#",
        "               ##*#######                 #.#.#          #.#.#",
        "            ####*******######             #.#.#          #.#.#",
        "           ...#***.****.*###....          #...#          #...#",
        "           ....**********##.....           ###            ###",
        "           ....****    *****....",
        "             ####        ####",
        "           ######        ######",
        "##############################################################",
        "#...#......#.##...#......#.##...#......#.##------------------#",
        "###########################################------------------#",
        "#..#....#....##..#....#....##..#....#....#####################",
        "##########################################    #----------#",
        "#.....#......##.....#......##.....#......#    #----------#",
        "##########################################    #----------#",
        "#.#..#....#..##.#..#....#..##.#..#....#..#    #----------#",
        "##########################################    ############",
    ]
for line in scene:
    print(line)

P1001 A+B Problem

A+B Problem

1
2
3
4
line = input()
nums = line.split()
a, b = int(nums[0]), int(nums[1])
print(a+b)

B2005 字符三角形

字符三角形

1
2
3
4
line = input()
print(f"  {line}")
print(f" {line * 3}")
print(f"{line * 5}")

P5703 【深基2.例5】苹果采购

【深基2.例5】苹果采购

1
2
3
line = input()
nums = line.split()
print(int(nums[0])*int(nums[1]))

P5704 【深基2.例6】字母转换

【深基2.例6】字母转换

1
2
letter = input()
print(letter.upper())

P5705 【深基2.例7】数字反转

【深基2.例7】数字反转

1
2
3
line = input()
rev = line[::-1]
print(float(rev))

P5706 【深基2.例8】再分肥宅水

【深基2.例8】再分肥宅水

1
2
3
4
word = input().split()
t, n = float(word[0]), int(word[1])
print(f"{t/n:.3f}")
print(f"{n*2}")

P5708 【深基2.习2】三角形面积

【深基2.习2】三角形面积

1
2
3
4
5
6
7
8
import math 

words = input().split()
a, b, c = float(words[0]), float(words[1]), float(words[2])
p = (a + b + c) / 2
s = math.sqrt(p*(p-a)*(p-b)*(p-c))

print(f"{s:.1f}")

P5707 【深基2.例12】上学迟到

【深基2.例12】上学迟到

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
import math

words = input().split()
s = float(words[0])  
t = float(words[1])  

total_time = 24 * 60  
cost = math.ceil(s / t) + 10
remain = total_time - cost

hh, mm = divmod(remain, 60)

if hh < 16:
    hh += 8
else:
    hh -= 16

print(f"{hh:02d}:{mm:02d}")

B2029 大象喝水

大象喝水

1
2
3
4
5
6
7
8
import math

words = input().split()
h, r = float(words[0]), float(words[1])
volume = 3.14 * r * r * h
cnt = math.ceil(20000.0/volume)

print(cnt)

P1425 小鱼的游泳时间

小鱼的游泳时间

1
2
3
4
5
words = input().split()
a, b, c, d = int(words[0]), int(words[1]), int(words[2]), int(words[3])
time = (c*60+d)-(a*60+b)
hh, mm = divmod(time, 60)
print(f"{hh:d} {mm:d}")

P1421 小玉买文具

小玉买文具

1
2
a, b = map(int, input().split())
print((10 * a + b) // 19)

P3954 [NOIP 2017 普及组] 成绩

[NOIP 2017 普及组] 成绩

1
2
3
a, b, c = map(float, input().split())
res = int(0.2*a + 0.3*b + 0.5*c)
print(res)
Licensed under CC BY-NC-SA 4.0
© 2023 - 2025 壹壹贰捌· 0Days
共书写了265.7k字·共 93篇文章 京ICP备2023035941号-1