TOPCODER_SRM580_DIV2_2---------枚举

Problem Statement

 Rabbit went to a river to catch eels. All eels are currently swimming down the stream at the same speed. Rabbit is standing by the river, downstream from all the eels.

Each point on the river has a coordinate. The coordinates increase as we go down the stream. Initially, Rabbit is standing at the origin, and all eels have non-positive coordinates.

You are given two vector <int>s: l and t. These describe the current configuration of eels. The speed of each eel is 1 (one). For each i, the length of eel number i is l[i]. The head of eel number i will arrive at the coordinate 0 precisely at the time t[i]. Therefore, at any time T the eel number i has its head at the coordinate T-t[i], and its tail at the coordinate T-t[i]-l[i].

Rabbit may only catch an eel when some part of the eel (between head and tail, inclusive) is at the same coordinate as the rabbit. Rabbit can catch eels at most twice. Each time he decides to catch eels, he may catch as many of the currently available eels as he wants. (That is, he can only catch eels that are in front of him at that instant, and he is allowed and able to catch multiple eels at once.)

Return the maximal total number of eels Rabbit can catch.

Definition

 
Class:EelAndRabbit
Method:getmax
Parameters:vector <int>, vector <int>
Returns:int
Method signature:int getmax(vector <int> l, vector <int> t)
(be sure your method is public)
 
 

Constraints

-l will contain between 1 and 50 elements, inclusive.
-Each element of l will be between 1 and 1,000,000,000, inclusive.
-l and t will contain the same number of elements.
-Each element of t will be between 0 and 1,000,000,000, inclusive.

Examples

0) 
 
{2, 4, 3, 2, 2, 1, 10}
{2, 6, 3, 7, 0, 2, 0}
Returns: 6
Rabbit can catch 6 eels in the following way:
  • At time 2, catch Eel 0, Eel 4, Eel 5, and Eel 6.
  • At time 8, catch Eel 1 and Eel 3.
1) 
 
{1, 1, 1}
{2, 0, 4}
Returns: 2
No two eels are in front of Rabbit at the same time, so Rabbit can catch at most two eels.
2) 
 
{1}
{1}
Returns: 1
3) 
 
{8, 2, 1, 10, 8, 6, 3, 1, 2, 5}
{17, 27, 26, 11, 1, 27, 23, 12, 11, 13}
Returns: 7

This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.     


题目意思:

有n个eels,告诉你们他的头,和长度,即t[i],和l[i]

然后要去抓捕他们,捕杀的人站在坐标为0的地方

然后这些鱼是会随着时间移动,速度一样,并且会经过0

只有当eel的身体的一部分位于0的时候才可以捕杀到

并且一次可以捕杀多个,然后最多可以捕杀2次

我们应该可以马上意识到,即使时间会变,但是整个的相对位置是不会变的,所以就不用管时间什么的了

可以把每个eel看作一条线段,那么如果线段有重叠部分的话,就表明可以一次捕杀

所以我们的目标就是怎么找出在两次内可以穿过最多的线段

解法就是:

我们可以任意枚举两个eel的头部,即表明我们的两次捕杀的位置是在这两个头部位于0时

那么对于其它的eel的话,只要身子和这两个头部有重叠的话,就可以捕杀到

然后找出最大的就OK啦

下面上代码:

#include<vector>
using namespace std;

class EelAndRabbit
{
    public:

    int getmax(vector<int> l,vector<int> t)
    {
        int len=l.size();
        if(len<=2)
            return len;
        int res=0;
        for(int i=0;i<len;i++)
        {
            for(int j=i+1;j<len;j++)
            {
                int ta=t[i];
                int tb=t[j];
                int tmp=0;
                for(int k=0;k<len;k++)
                {
                    if((t[k]<=ta && t[k]+l[k]>=ta) || (t[k]<=tb&&t[k]+l[k]>=tb))
                        tmp++;
                }
                if(tmp>res)
                    res=tmp;
            }
        }
        return res;
    }
};





内容概要:本文详细探讨了杯形谐波减速器的齿廓修形方法及寿命预测分析。文章首先介绍了针对柔轮与波发生器装配时出现的啮合干涉问题,提出了一种柔轮齿廓修形方法。通过有限元法装配仿真确定修形量,并对修形后的柔轮进行装配和运转有限元分析。基于Miner线性疲劳理论,使用Fe-safe软件预测柔轮寿命。结果显示,修形后柔轮装配最大应力从962.2 MPa降至532.7 MPa,负载运转应力为609.9 MPa,解决了啮合干涉问题,柔轮寿命循环次数达到4.28×10⁶次。此外,文中还提供了详细的Python代码实现及ANSYS APDL脚本,用于柔轮变形分析、齿廓修形设计、有限元验证和疲劳寿命预测。 适合人群:机械工程领域的研究人员、工程师,尤其是从事精密传动系统设计和分析的专业人士。 使用场景及目标:①解决杯形谐波减速器中柔轮与波发生器装配时的啮合干涉问题;②通过优化齿廓修形提高柔轮的力学性能和使用寿命;③利用有限元分析和疲劳寿命预测技术评估修形效果,确保设计方案的可靠性和可行性。 阅读建议:本文涉及大量有限元分析和疲劳寿命预测的具体实现细节,建议读者具备一定的机械工程基础知识和有限元分析经验。同时,读者可以通过提供的Python代码和ANSYS APDL脚本进行实际操作和验证,加深对修形方法和技术路线的理解。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值