hdu 1140:War on Weather(计算几何,水题)

本文介绍了一道关于计算几何的问题,模拟卫星攻击地球表面目标的过程。通过简单的几何运算判断卫星能否攻击到特定的目标,旨在展示如何利用基本的数学原理解决实际问题。

War on Weather

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 300    Accepted Submission(s): 162


Problem Description
After an unprovoked hurricane attack on the south shore, Glorious Warrior has declared war on weather. The first salvo in this campaign will be a coordinated pre-emptive attack on as many tropical depressions as possible. GW reckons that the attack will neutralize the tropical depressions before they become storms, and dissuade others from forming. 
GW has at his disposal k space-to-earth killer satellites at various locations in space. m tropical depressions are known to exist at various locations on the earth's surface. Each satellite can attack any number of targets on the earth provided there is line of sight between the satellite and each target. How many different targets can be hit? 
 

 

Input
The input consists of several test cases. Each case begins with a line containing integers 0 < k, m &le 100 as defined above. k lines follow, each giving x,y,z - the location in space of a satellite at the scheduled time of attack. m lines then follow, each giving x,y,z - the location of a target tropical depression. Assume the earth is a sphere centred at (0,0,0) with circumference 40,000 km. All targets will be on the surface of the earth (within 10-9 km) and all satellites will be at least 50 km above the surface. A line containing 0 0 follows the last test case. 
 

 

Output
For each test case, output a line giving the total number of targets that can be hit. If a particular target falls within 10-8 km of the boundary between being within line-of-sight and not, it may be counted either way. (That is, you need not consider rounding error so long as it does not exceed 10-8 km.) 
 

 

Sample Input
3 2
-10.82404031 -1594.10929753 -6239.77925152
692.58497298 -5291.64700245 4116.92402298
3006.49210582 2844.61925179 5274.03201053
2151.03635167 2255.29684503 5551.13972186
-1000.08700886 -4770.25497971 4095.48127333
3 4
0 0 6466.197723676
0 6466.197723676 0
6466.197723676 0 0
6366.197723676 0 0
6365.197723676 112.833485488 0
0 0 6366.197723676
0 -6366.197723676 0
0 0
 

 

Sample Output
2
3
 

 

Source
 

 

Recommend
Eddy   |   We have carefully selected several similar problems for you:   1145  1142  1154  1144  1143 
 
  计算几何的水题
  没有用到复杂的算法,用基本的几何知识即可解决这道题。
  题意:给你k个卫星的坐标,m个目标的坐标(在地球上),问能这些卫星能击中几个目标。卫星只能击中面对着地球的那一面,背对着它的那一面无法击中。
  思路:如果 卫星到目标的距离 > 卫星到切点的距离(作卫星到地球的切线,切线与地球的交点为切点),说明目标在当前卫星面对的地球的背面,无法击中。
  代码
 1 #include <iostream>
 2 #include <cmath>
 3 using namespace std;
 4 //#define PI 3.1415926
 5 #define PI acos(-1.0)        //产生精确的圆周率PI
 6 struct Point3{
 7     double x,y,z;
 8 };
 9 double dist3(Point3 p0,Point3 p1)
10 {
11     return sqrt((p1.x-p0.x)*(p1.x-p0.x) + (p1.y-p0.y)*(p1.y-p0.y) + (p1.z-p0.z)*(p1.z-p0.z));
12 }
13 Point3 K[110];
14 int main()
15 {
16     int k,m;
17     while(cin>>k>>m){
18         if(k==0 && m==0) break;
19         double r = 40000.0 / (2 * PI);    //地球半径
20         int i;
21         for(i=1;i<=k;i++)
22             cin>>K[i].x>>K[i].y>>K[i].z;
23         int sum = 0;    //记录有几个目标能被打击到
24         for(i=1;i<=m;i++){
25             Point3 M;    //目标
26             cin>>M.x>>M.y>>M.z;
27             Point3 o;    //地球球心
28             o.x=0,o.y=0,o.z=0;
29             int j;    
30             for(j=1;j<=k;j++){    //看哪个卫星能打到目标,找到了就立刻退出循环
31                 double k2o = dist3(K[j],o);    //当前卫星到地球球心的距离
32                 double k2m = dist3(K[j],M);    //卫星到目标的距离
33                 if( k2m*k2m <= k2o*k2o-r*r )
34                     break;
35             }
36             if(j<=k)
37                 sum++;
38         }
39         cout<<sum<<endl;
40     }
41     return 0;
42 }

 

Freecode : www.cnblogs.com/yym2013

转载于:https://www.cnblogs.com/yym2013/p/3632793.html

内容概要:本文围绕“基于交流潮流的电力系统多元件N-k故障模型研究”展开,深入探讨了利用Matlab代码实现电力系统在发生多个关键元件同时故障(即N-k故障)情况下的交流潮流计算与故障分析方法。该模型不仅考虑了传统潮流方程的非线性特性,还引入了故障约束条件,能够精确模拟复杂多样的故障场景,如短路、断线等,进而评估电网在极端运行条件下的稳态与动态行为。研究通过构建典型电力系统算例,验证了所提模型在故障筛选、脆弱性识别及系统恢复策略制定方面的有效性,为电力系统安全评估、风险预警和防御体系构建提供了坚实的理论依据和技术支撑。此外,模型具备良好的扩展性,可进一步应用于连锁故障传播分析、恶意攻击模拟等高级安全分析领域。; 适合人群:具备电力系统分析基础理论知识和Matlab编程能力的高校研究生、科研院所研究人员以及电力公司从事电网规划、运行与安全管理的技术人员,特别适用于开展电力系统安全稳定、可靠性评估与应急响应机制研究的专业人士。; 使用场景及目标:①开展电力系统在多重故障条件下的交流潮流仿真,评估系统电压稳定性、线路过载风险及负荷损失程度;②识别电网中的关键薄弱环节与脆弱元件,支撑电网加固改造与防御资源配置;③用于科研项目中的故障场景建模与算法验证,或作为教学案例帮助学生理解复杂故障下的系统响应机制。; 阅读建议:此资源以Matlab代码为核心实现手段,建议读者结合理论推导与代码实现进行对照学习,重点关注故障建模过程中雅可比矩阵的修正方法、故障注入方式及收敛性处理策略,建议在仿真中逐步增加故障数量与复杂度,深入理解N-k故障对系统潮流分布的影响规律,并尝试将其拓展至含新能源接入的现代电力系统场景中进行验证与优化。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值