Codeforces Round 926 (Div. 2)(A~C)python

A. Sasha and the Beautiful Array

Problem - A - Codeforces

签到题,贪心,排序

可以发现最后的结果为最后一个元素减第一个元素,分别取最大和最小,此时得到的结果最大

t = int(input())
for _ in range(t):
    n = int(input())
    a = list(map(int, input().split()))
    res = max(a)-min(a)
    print(res)

B. Sasha and the Drawing

Problem - B - Codeforces

贪心,数学

涂一格多两条对角线的格子数为2n-2个,这样前4n-4条都可以用这些格子构成,

剩下的两条线每条则会使用1个格子

from math import ceil
t = int(input())
for _ in range(t):
    n, k = map(int, input().split())
    two = 4*n-4
    if k <= two:
        res = ceil(k/2)
    else:
        res = two//2+k-two
    print(res)

C. Sasha and the Casino

Problem - C - Codeforces

贪心,暴力,数学

赌场可以任意操控胜负,那么Sasha要保证何时赢了,都总能把前面输的钱赢回来且有得赚,所以每次输了后要下注更多的钱

这时赌场会让Sasha一直输,直到x轮后使其赢一局(赌徒思维不可取啊。。。)

要保证他的硬币数足以撑到x+1回合,这时不限轮数就可以赚到任意多的钱

每次下注的钱为之前输的钱need//(k-1)+1,前面输的钱累加起来,判断他的钱是否足够

def check():
    need = 1
    for i in range(x):
        now = need//(k-1)+1
        need += now
    return a >= need


t = int(input())
for _ in range(t):
    k, x, a = map(int, input().split())
    if check():
        print("YES")
    else:
        print("NO")

  • 11
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值