速度坐标hdu4445Crazy Tank

工作之余抽点时间出来写写博文,希望对新接触的朋友有帮助。今天在这里和大家一起学习一下速度坐标

    http://acm.hdu.edu.cn/showproblem.php?pid=4445

    直接应用速度公式求解,采取的是应用枚举三角函数值来计算;  

    由发射塔到地面的速度公式为   v0 * v0  -  vy *  vy = 2 * g * h ( v0 为末速度,均为竖直方向的速度 )

                                                      然后计算水平距离l ,应用l 与敌方和友方坐标停止比较, 当位于友方坐标内,直接跳出循环 ;

    每日一道理
自己把自己说服了,是一种理智的胜利;自己被自己感动了,是一种心灵的升华;自己把自己征服了,是一种人生的成功。
// File Name: 4445.cpp
// Author: bo_jwolf
// Created Time: 2013年05月24日 星期五 13:28:41

#include<vector>
#include<list>
#include<map>
#include<set>
#include<deque>
#include<stack>
#include<queue>
#include<bitset>
#include<algorithm>
#include<functional>
#include<numeric>
#include<utility>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<ctime>

using namespace std;
int n ;
double h , l1 , r1 ,l2 , r2 ;
const int maxn = 1005 ;
double a[ maxn ] ;
const double g = -9.8 ;

int ff( int x )
{
	double sy = x / 10000.0 ;
	double sx = sqrt( 1.0 - sy * sy ) ;
	int sum = 0 ;
	for(int  i = 0 ; i < n ; i++ )
	{
		double vy = a[ i ] * sy  ;
		double t = ( - 1.0 *vy  - sqrt( vy * vy + 2 * g * h ) ) / g ;
		double l =  a[ i ] * sx * t ;
		if( l >= l2 && l <= r2 )
			return 0 ; 
		if( l >= l1 && l <= r1 )
			sum++ ;
	}
	return sum ;
}

int main()
{
	int Case ;
	int ans ;
//	freopen("cin.txt", "r", stdin);
	while( scanf( "%d" , &n ) && n)
	{
			scanf( "%lf%lf%lf%lf%lf" , &h , &l1 , &r1 , &l2 ,&r2 ) ;
			for( int i = 0 ; i < n ; i++ )
			{
				scanf( "%lf" , &a[ i ] ) ;
			}
			ans = 0 ;
			h = -1.0 * h ;
			for(int  i = -10000 ; i < 10000 ; i++ )
			{
				int x = ff( i ) ;
				if( x > ans ) 
					ans = x ; 
			}
			printf( "%d\n" , ans ) ;
		
	}
return 0;
}

文章结束给大家分享下程序员的一些笑话语录: 腾讯的动作好快,2010年3月5日19时28分58秒,QQ同时在线人数1亿!刚刚看到编辑发布的文章,相差才2分钟,然后连专题页面都做出来了,他们早就预料到了吧?(其实,每人赠送10Q币,轻轻松松上两亿!)

--------------------------------- 原创文章 By
速度和坐标
---------------------------------

原文地址:https://www.cnblogs.com/xinyuyuanm/p/3098160.html