欢乐赛26python题解
2024-07-30 11:05:58
发布于:广东
T1 消息堆积
n = int(input())
if n >= 99:
print("99+")
else:
print(n)
T2
下雨天
n = int(input())
if n > 0:
print("YES")
else:
print("NO")
T3
QQ捏捏好喝到咩噗咩噗奶茶
import math
n, m, k, v = map(int, input().split())
total_cost = 0
full_price_cups = n % k
discounted_cups = n - full_price_cups
discounted_price = (v * 7) // 10
total_cost = full_price_cups * v + discounted_cups * discounted_price
if total_cost <= m:
print("YES")
print(m - total_cost)
else:
print("NO")
print(total_cost - m)
T4
甜筒在哪里
n, x = map(int, input().split())
a = list(map(int, input().split()))
result = -1
for num in a:
if num < x and num % 2 == 0:
result = max(result, num)
print(result)
T5
字符变换
def can_transform(A, B):
A = sorted(A)
B = sorted(B)
return A == B
A = input()
B = input()
if can_transform(A, B):
print("YES")
else:
print("NO")
T6
判断子序列
def is_subsequence(s, t):
i, j = 0, 0
while i < len(s) and j < len(t):
if s[i] == t[j]:
i += 1
j += 1
return i == len(s)
s = input()
t = input()
if is_subsequence(s, t):
print("YES")
else:
print("NO")
T7
16进制加法
A = int(input(), 16)
B = int(input(), 16)
sum = A + B
print(f"0X{sum:X}")
T8
X Y A B
def gcd(a, b):
while b != 0:
a, b = b, a % b
return a
def lcm(a, b):
return a // gcd(a, b) * b
def countDivisible(x, y, a, b):
lcm_ab = lcm(a, b)
total = y - x + 1
divisible_by_a = y // a - (x - 1) // a
divisible_by_b = y // b - (x - 1) // b
divisible_by_both = y // lcm_ab - (x - 1) // lcm_ab
return total - divisible_by_a - divisible_by_b + divisible_by_both
x, y, a, b = map(int, input().split())
print(countDivisible(x, y, a, b))
全部评论 10
顶
2024-07-29 来自 广东
166
2024-07-29 来自 广东
06
2024-07-29 来自 广东
06
2024-07-29 来自 广东
0
顶
2024-07-29 来自 广东
1顶顶
2024-07-29 来自 广东
1球球了
2024-07-29 来自 广东
1ac君置顶
2024-07-29 来自 广东
1你也是蒟蒻上了
2024-08-02 来自 湖南
0嘿嘿嘿,童哥帮我看到题
小码君的桌子上放着 n 根香蕉,从左到右排成一列,编号为从 1 到 n。 小 A 是小码君的好朋友,每天她都会从中拿走一些香蕉。 每天在拿的时候,小 A 都是从左侧第 1 根香蕉开始、每隔 2 根香蕉拿走 1 根香蕉。随后小 A 会将剩下的香蕉按原先的顺序重新排成一列。 小 A 想知道,多少天能拿完所有的香蕉,而编号为 n 的香蕉是在第几天被拿走的? 输入格式 输入的第一行包含一个正整数 n,表示香蕉的总数。 输出格式 输出一行包含两个正整数,两个整数之间由一个空格隔开,分别表示小 A 拿走所有香蕉所需的天数以及拿走编号为 n 的香蕉是在第几天。 样例组 输入#1 复制 8 输出#1 复制 5 5 输入#2 复制 125 输出#2 复制 11 3 提示说明 【样例 1 解释】 小 A的桌上一共放了 8 个香蕉。 小 A第一天拿走了编号为 1、4、7 的香蕉。 小 A第二天拿走了编号为 2、6 的香蕉。 小 A第三天拿走了编号为 3 的香蕉。 小 A第四天拿走了编号为 5 的香蕉。 小 A第五天拿走了编号为 8 的香蕉。 【数据范围】 对于所有测试数据有:1≤n≤10 9 。 测试点 n≤ 特殊性质 1∼2 10 无 3∼5 10 3 无 6∼7 10 6 有 8∼9 10 6 无 10 10 9 无 特殊性质:小 A第一天就取走编号为 n 的香蕉。
2024-08-02 来自 浙江
0童哥,童爸,童爷
2024-08-02 来自 浙江
0这么简单,你不是有GPT吗
2024-08-02 来自 湖南
0
啥也没写就置顶了
2024-07-29 来自 湖南
0不是你凭什么啊
2024-07-29 来自 湖南
0oͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅoͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅoͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅͅ
2024-07-29 来自 浙江
0顶
2024-07-29 来自 北京
0
有帮助,赞一个