B - Toy Storage poj2398

解决父母为孩子玩具乱放的问题,通过在玩具箱中设置隔板将玩具按区分开,算法计算每个区域内的玩具数量,帮助孩子更容易找到自己喜爱的玩具。

Mom and dad have a problem: their child, Reza, never puts his toys away when he is finished playing with them. They gave Reza a rectangular box to put his toys in. Unfortunately, Reza is rebellious and obeys his parents by simply throwing his toys into the box. All the toys get mixed up, and it is impossible for Reza to find his favorite toys anymore.
Reza’s parents came up with the following idea. They put cardboard partitions into the box. Even if Reza keeps throwing his toys into the box, at least toys that get thrown into different partitions stay separate. The box looks like this from the top:
在这里插入图片描述

We want for each positive integer t, such that there exists a partition with t toys, determine how many partitions have t, toys.
Input
The input consists of a number of cases. The first line consists of six integers n, m, x1, y1, x2, y2. The number of cardboards to form the partitions is n (0 < n <= 1000) and the number of toys is given in m (0 < m <= 1000). The coordinates of the upper-left corner and the lower-right corner of the box are (x1, y1) and (x2, y2), respectively. The following n lines each consists of two integers Ui Li, indicating that the ends of the ith cardboard is at the coordinates (Ui, y1) and (Li, y2). You may assume that the cardboards do not intersect with each other. The next m lines each consists of two integers Xi Yi specifying where the ith toy has landed in the box. You may assume that no toy will land on a cardboard.

A line consisting of a single 0 terminates the input.
Output
For each box, first provide a header stating “Box” on a line of its own. After that, there will be one line of output per count (t > 0) of toys in a partition. The value t will be followed by a colon and a space, followed the number of partitions containing t toys. Output will be sorted in ascending order of t for each box.
Sample Input
4 10 0 10 100 0
20 20
80 80
60 60
40 40
5 10
15 10
95 10
25 10
65 10
75 10
35 10
45 10
55 10
85 10
5 6 0 10 60 0
4 3
15 30
3 1
6 8
10 10
2 1
2 8
1 5
5 5
40 10
7 9
0
Sample Output
Box
2: 5
Box
1: 4
2: 1

和poj2318差不多 多了一个线段排序

#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<iostream>
#include<vector>
#include<set>
#include<stack>
#include<map>
#include<queue>
typedef long long ll;
using namespace std;
const int N=5005;
const int INF=0x3f3f3f3f3f;
int n;
int vis[N];int toy[N];
struct node
{
    int x,y;
};
struct Line
{
    node pu;
    node pl;
}line[N];
bool cmp(Line p,Line q)
{
    return min(p.pu.x,p.pl.x)<min(q.pu.x,q.pl.x)||(min(p.pl.x,p.pu.x)==min(q.pl.x,q.pu.x)&&max(p.pl.x,p.pu.x)<max(q.pl.x,q.pu.x));
}
int multi(node p1,node p2,node p0)
{
    int x1,y1,x2,y2;
    x1=p1.x-p0.x;y1=p1.y-p0.y;
    x2=p2.x-p0.x;y2=p2.y-p0.y;
    return x1*y2-x2*y1;
}
int sea(node t)
{
    int l=0,r=n-1,mid;
    while(l<r)
    {
        mid=(l+r)>>1;
        if(multi(line[mid].pu,line[mid].pl,t)>0)
        {
            l=mid+1;
        }
        else
        {
            r=mid;
        }
    }
    if(multi(line[l].pu,line[l].pl,t)<0)
        toy[l]++;
    else
        toy[l+1]++;
}
int main()
{
    while(scanf("%d",&n)!=EOF)
    {
        if(n==0)
            break;
        int m,x1,x2,y1,y2;
        memset(vis,0,sizeof(vis));
        memset(toy,0,sizeof(toy));
        scanf("%d%d%d%d%d",&m,&x1,&y1,&x2,&y2);
        int ui,li;
        for(int i=0; i<n; i++)
        {
            scanf("%d%d",&ui,&li);
            line[i].pu.x=ui;
            line[i].pl.x=li;
            line[i].pu.y=y1;
            line[i].pl.y=y2;
        }
        sort(line,line+n,cmp);
        node t;
        for(int i=1; i<=m; i++)
        {
            scanf("%d%d",&t.x,&t.y);
            sea(t);
        }
        for(int i=0;i<=n;i++)
        {
            vis[toy[i]]++;
        }
        printf("Box\n");
        for(int i=1;i<=m;i++)
        {
            if(vis[i])
            {
                printf("%d: %d\n",i,vis[i]);
            }
        }
    }
    return 0;
}

【四轴飞行器】非线性三自由度四轴飞行器模拟器研究(Matlab代码实现)内容概要:本文围绕非线性三自由度四轴飞行器的建模与仿真展开,重点介绍了基于Matlab的飞行器动力学模型构建与控制系统设计方法。通过对四轴飞行器非线性运动方程的推导,建立其在三维空间中的姿态与位置动态模型,并采用数值仿真手段实现飞行器在复杂环境下的行为模拟。文中详细阐述了系统状态方程的构建、控制输入设计以及仿真参数设置,并结合具体代码实现展示了如何对飞行器进行稳定控制与轨迹跟踪。此外,文章还提到了多种优化与控制策略的应用背景,如模型预测控制、PID控制等,突出了Matlab工具在无人机系统仿真中的强大功能。; 适合人群:具备一定自动控制理论基础和Matlab编程能力的高校学生、科研人员及从事无人机系统开发的工程师;尤其适合从事飞行器建模、控制算法研究及相关领域研究的专业人士。; 使用场景及目标:①用于四轴飞行器非线性动力学建模的教学与科研实践;②为无人机控制系统设计(如姿态控制、轨迹跟踪)提供仿真验证平台;③支持高级控制算法(如MPC、LQR、PID)的研究与对比分析; 阅读建议:建议读者结合文中提到的Matlab代码与仿真模型,动手实践飞行器建模与控制流程,重点关注动力学方程的实现与控制器参数调优,同时可拓展至多自由度或复杂环境下的飞行仿真研究。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值