poj1285 Agri-Net(最短路)

市长 Farmer John 计划通过铺设最少的光纤来实现农场间的互联网连接。任务是找到一种方案,确保任意两个农场间都能传递数据包,同时最小化光纤总长度。
<div class="ptt" lang="en-US" style="text-align: center; font-size: 18pt; font-weight: bold; color: blue;">Agri-Net</div><div class="plm" style="text-align: center;font-size:14px;"><table align="center"><tbody><tr><td><strong>Time Limit:</strong> 1000MS</td><td width="10px"> </td><td><strong>Memory Limit:</strong> 10000K</td></tr><tr><td><strong>Total Submissions:</strong> 51426</td><td width="10px"> </td><td><strong>Accepted:</strong> 21441</td></tr></tbody></table></div><p class="pst" style="font-size: 18pt; font-weight: bold; color: blue;">Description</p><div class="ptx" lang="en-US" style="font-family: "Times New Roman", Times, serif;font-size:14px;">Farmer John has been elected mayor of his town! One of his campaign promises was to bring internet connectivity to all farms in the area. He needs your help, of course. 
Farmer John ordered a high speed connection for his farm and is going to share his connectivity with the other farmers. To minimize cost, he wants to lay the minimum amount of optical fiber to connect his farm to all the other farms. 
Given a list of how much fiber it takes to connect each pair of farms, you must find the minimum amount of fiber needed to connect them all together. Each farm must connect to some other farm such that a packet can flow from any one farm to any other farm. 
The distance between any two farms will not exceed 100,000. 
</div><p class="pst" style="font-size: 18pt; font-weight: bold; color: blue;">Input</p><div class="ptx" lang="en-US" style="font-family: "Times New Roman", Times, serif;font-size:14px;">The input includes several cases. For each case, the first line contains the number of farms, N (3 <= N <= 100). The following lines contain the N x N conectivity matrix, where each element shows the distance from on farm to another. Logically, they are N lines of N space-separated integers. Physically, they are limited in length to 80 characters, so some lines continue onto others. Of course, the diagonal will be 0, since the distance from farm i to itself is not interesting for this problem.</div><p class="pst" style="font-size: 18pt; font-weight: bold; color: blue;">Output</p><div class="ptx" lang="en-US" style="font-family: "Times New Roman", Times, serif;font-size:14px;">For each case, output a single integer length that is the sum of the minimum length of fiber required to connect the entire set of farms.</div><p class="pst" style="font-size: 18pt; font-weight: bold; color: blue;">Sample Input</p><pre class="sio" style="font-family: "Courier New", Courier, monospace;font-size:14px;">4
0 4 9 21
4 0 8 17
9 8 0 16
21 17 16 0

Sample Output

28

Source




#include<stdio.h>
#include<string.h>
int INF = 0x3f3f3f3f;
int main()
{
    int t;
    int n,m;
    int i,j,k;
    int map[550][550];
    int book[550];
    int dis[550];
    int sum;
    //scanf("%d",&t);
    while(~scanf("%d",&n))
    {
      sum=0;
        //memset(map,0,sizeof(map));
        memset(book,0,sizeof(book));
        memset(dis,0,sizeof(dis));
        for(i = 1; i <=n ;i++)
        {
            for( j = 1; j <=n ;j++)
                scanf("%d",&map[i][j]);
        }
        book[1]=1;
        for( i = 1; i <= n; i++)
            dis[i] = map[1][i];
        int step = 1;
        int max = -1;
        int min;
        while(step < n)
        {
           min =  INF;
           for( i=1; i <=n; i++)
           {
               if(!book[i]&&dis[i]<min)
               {
                   min = dis[i];
                   j = i;
               }
           }
           book[j] = 1;
           step++;

           //if(max < min)
           //   max=min;
             sum+=min;
              for( k = 1; k <= n; k++)
              {
                  if(!book[k] && dis[k] > map[j][k])
                    dis[k]=map[j][k];
              }


        }
        printf("%d\n",sum);
    }
    return 0;
}

【四轴飞行器】非线性三自由度四轴飞行器模拟器研究(Matlab代码实现)内容概要:本文围绕非线性三自由度四轴飞行器模拟器的研究展开,重点介绍基于Matlab代码实现的四轴飞行器动力学建模与仿真方法。研究构建了考虑非线性特性的飞行器数学模型,涵盖姿态动力学与运动学方程,实现了三自由度(滚转、俯仰、偏航)的精确模拟。文中详细阐述了系统建模过程、控制算法设计思路及仿真结果分析,帮助读者深入理解四轴飞行器的飞行动力学特性与控制机制;同时,该模拟器可用于算法验证、控制器设计与教学实验。; 适合人群:具备一定自动控制理论基础和Matlab编程能力的高校学生、科研人员及无人机相关领域的工程技术人员,尤其适合从事飞行器建模、控制算法开发的研究生和初级研究人员。; 使用场景及目标:①用于四轴飞行器非线性动力学特性的学习与仿真验证;②作为控制器(如PID、LQR、MPC等)设计与测试的仿真平台;③支持无人机控制系统教学与科研项目开发,提升对姿态控制与系统仿真的理解。; 阅读建议:建议读者结合Matlab代码逐模块分析,重点关注动力学方程的推导与实现方式,动手运行并调试仿真程序,以加深对飞行器姿态控制过程的理解。同时可扩展为六自由度模型或加入外部干扰以增强仿真真实性。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值