[acwing周赛复盘] 第 61 场周赛20220723

博主分享了第61场ACwing周赛的参赛总结,重点讨论了三道题目:4497.分糖果(签到题,通过平均分配求解),4498.指针(通过DFS枚举解决),4499.画圆(涉及几何计算,根据条件确定最大圆)。博主详细分析了思路并提供了代码实现。
摘要由CSDN通过智能技术生成

一、本周周赛总结

  • 第三题几何题,先再草稿纸上推了半天公式,又去现场查python保留几位小数怎么写。
  • 最后还是wa半天。
  • 而且第三题答案不唯一。在这里插入图片描述

在这里插入图片描述

二、 4497. 分糖果

链接: 4497. 分糖果

1. 题目描述

在这里插入图片描述

2. 思路分析

定级Easy。
签到题,就硬写。

3. 代码实现

import io
import os
import sys
from collections import deque

if os.getenv('LOCALTESTACWING'):
    sys.stdin = open('input.txt')

if __name__ == '__main__':
    T = int(input())
    for _ in range(T):
        a,b,c = map(int, input().split())
        print((a+b+c)//2)


三、4498. 指针

链接: 4498. 指针

1. 题目描述

在这里插入图片描述

2. 思路分析

  • 一开始没好思路,看了下数据范围15,那么直接dfs枚举。

3. 代码实现

import io
import os
import sys
from collections import deque

if os.getenv('LOCALTESTACWING'):
    sys.stdin = open('input.txt')

if __name__ == '__main__':
    n = int(input())
    arr = []
    for _ in range(n):
        arr.append(int(input()))
    m = len(arr)

    def dfs(index, s):
        if index == m:
            if s % 360 == 0:
                return True
            return False
        if dfs(index + 1, s + arr[index]):
            return True
        return dfs(index + 1, s - arr[index])


    print('YES' if  dfs(0, 0) else 'NO')

四、4499. 画圆

链接: 4499. 画圆

1. 题目描述

在这里插入图片描述

2. 思路分析

几何题。

  • 条件一代表你的圆要在给定圆(x1,y1,R)内。
  • 条件二代表你的圆不能覆盖给定点(x2,y2),但可以接触(定着它)。
  • 条件三代表你的圆要尽可能大,那么也就是说你的圆要顶着这个点使劲膨胀。

  • 特判如果给定点不在圆内,那我们能构造的圆就是给定圆,直接调整小数点输出即可。
  • 如果在圆内,且是圆心,那我们的圆直径就是给定圆的半径,显然圆心位置在圆里绕着给定圆心滚动即可随便取,无限种可能,这里把y固定。
  • 剩下的情况就需要套公式,可以看我下边的图,代码直接套结论。

3. 代码实现

import io
import os
import sys
from collections import deque

if os.getenv('LOCALTESTACWING'):
    sys.stdin = open('input.txt')


def sovle(R, x1, y1, x2, y2):
    if (y1 - y2) ** 2 + (x1 - x2) ** 2 >= R ** 2:
        return print("%.6f" % (x1 * 1.0), "%.6f" % (y1 * 1.0), "%.6f" % (R * 1.0))

    if x1 == x2 and y1 == y2:
        return print("%.6f" % ((x1 + R/2) ), "%.6f" % (y1 * 1.0), "%.6f" % (R / 2))
    
    c = ((y1 - y2) ** 2 + (x1 - x2) ** 2) ** 0.5

    c2 = c + R
    y3 = (y2 - c2 * (y2 - y1) / c)
    x3 = (x2 - c2 * (x2 - x1) / c)
    y4 = (y3 + y2) / 2
    x4 = (x3 + x2) / 2
    r = c2 / 2
    print("%.6f" % x4, "%.6f" % y4, "%.6f" % r)


if __name__ == '__main__':
    R, x1, y1, x2, y2 = map(int, input().split())
    sovle(R, x1, y1, x2, y2)


六、参考链接

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值