圆形奖章给定半径的半径和圆形区域。另一个硬币的半径,然后在桌面上平稳。给定硬币的速(的大小和方向,vx,vy)和坐标(奖牌同心圆形区域,圆和心脏为源),Q币在一个圆形区域和多少下滑(不管是什么圆形区域的一部分被认为是),币碰到圆奖牌会反弹。能量不变(速度不变)

第一次做平面几何题

看了题解,题解的板子真好用

大概来说有三种情况。例如以下图

第一种是进入圆区而不碰撞,查看h和Rm+r的关系

另外一种是进入圆区且碰撞,查看h和Rm+r的关系

第三种是不进入圆区。查看方向向量和圆心到初始点向量这两个向量的夹角还有h和R+r的关系。并且应该先看向量,也能够先看R+r再讨论向量

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#define PI acos(-1.0)
#define maxn 100005
#define INF 0x7fffffff
#define eps 1e-8
using namespace std;
int cmp(double x) {
if(fabs(x)<eps)
return 0;
if(x>0)
return 1;
return -1;
}
inline int sgn(double n) {
return fabs(n)<eps? 0:(n<0?-1:1);
}
inline double sqr(double x) {
return x*x;
}
struct point{
double x,y;
point() {}
point(double a,double b):x(a),y(b) {}
void input() {
scanf("%lf%lf",&x,&y);
}
friend point operator + (const point &a,const point &b) {
return point(a.x+b.x,a.y+b.y);
}
friend point operator - (const point &a,const point &b) {
return point(a.x-b.x,a.y-b.y);
}
friend bool operator == (const point &a,const point &b) {
return cmp(a.x-b.x)==0 &&cmp(a.y-b.y)==0;
}
friend point operator * (const point &a,const double &b) {
return point(a.x*b,a.y*b);
}
friend point operator * (const double &a,const point &b) {
return point(a*b.x,a*b.y);
}
friend point operator / (const point &a,const double &b) {
return point(a.x/b,a.y/b);
}
double norm() {
return sqrt(sqr(x)+sqr(y));
}//到原点距离
void out () const {
printf("%.2f %.2f",x,y);
}
};
double det (const point &a,const point &b) {
return a.x*b.y-a.y*b.x;
}//叉积
double dot (const point &a,const point &b) {
return a.x*b.x+a.y*b.y;
}//点乘
double dist (const point &a,const point &b) {
return (a-b).norm();
}//距离
point rotate_point(const point &p,double A) {
double tx=p.x,ty=p.y;
return point (tx*cos(A)-ty*sin(A),tx*sin(A)+ty*cos(A));
}//旋转,A是弧度
struct line {
point a,b;
line() {}
line(point x,point y):a(x),b(y) {}
point dire()const {
return b-a;
}//向量
double len() {
return dire().norm();
}
};
bool parallel(line a,line b) {
return !cmp(det(a.a-a.b,b.a-b.b));
}
bool line_make_point (line a,line b,point &res) {
if(parallel(a,b))
return false;
double s1=det(a.a-b.a,b.b-b.a);
double s2=det(a.b-b.a,b.b-b.a);
res=(s1*a.b-s2*a.a)/(s1-s2);
return true;
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("/home/rainto96/in.txt","r",stdin);
#endif
double Rm,R,r,x,y,vx,vy;
while(~scanf("%lf%lf%lf%lf%lf%lf%lf",&Rm,&R,&r,&x,&y,&vx,&vy)){
point s=point(x,y);
point dir=point(vx,vy);
if(dot(s,dir)>=0){
printf("0.000\n");
continue;
}
point tmp=point(vy,-vx);
line l1=line(point(0,0),tmp);
line l2=line(s,point(s.x+vx,s.y+vy));
point ans;
line_make_point(l1,l2,ans);
double h=ans.norm();
double h1=R+r;
double h2=Rm+r;
double speed=sqrt(vx*vx+vy*vy);
if(h>=h1){
printf("0.000\n");
continue;
}
if(h>=h2){
double time=sqrt(h1*h1-h*h)/speed*2;
printf("%f\n",time);
continue;
}else{
double time=sqrt(h1*h1-h*h)-sqrt(h2*h2-h*h);
time=time/speed*2;
printf("%f\n",time);
continue;
}
}
return 0;
}

版权声明:本文博客原创文章,博客,未经同意,不得转载。

HDU 4793 2013 Changsha Regional Collision[简单的平面几何]的更多相关文章

  1. 2013 Changsha Regional 一样的木板一样的气球

    气球:      木板:   比赛现场: 场外: 曲线....  除了第一题出的太慢了,总体比成都好了很多.... 自此,今年两铜收场,再接再厉,明年要有更好的成绩.

  2. HDU 4793 Collision (2013长沙现场赛,简单计算几何)

    Collision Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total S ...

  3. 2013 Asia Changsha Regional Contest---Josephina and RPG(DP)

    题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=4800 Problem Description A role-playing game (RPG and ...

  4. 致初学者(一): HDU 2000~ 2013题解

    对于开始学习C语言程序设计或C++程序设计面向过程部分的同学来说,利用在线OJ网站进行实践训练,对提高自己的编程能力很有好处.国内外OJ网站很多,每个都去看看,去刷个题,是不现实的,也没必要.即使一个 ...

  5. 2013 Asia Regional Changchun C

    Little Tiger vs. Deep Monkey Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K ( ...

  6. HDU 5795 A Simple Nim(简单Nim)

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

  7. HDU 5073 Galaxy (2014 Anshan D简单数学)

    HDU 5073 Galaxy (2014 Anshan D简单数学) 题目链接http://acm.hdu.edu.cn/showproblem.php?pid=5073 Description G ...

  8. HDU 4793 Collision(2013长沙区域赛现场赛C题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4793 解题报告:在一个平面上有一个圆形medal,半径为Rm,圆心为(0,0),同时有一个圆形范围圆心 ...

  9. HDU 4793 Collision (解二元一次方程) -2013 ICPC长沙赛区现场赛

    题目链接 题目大意 :有一个圆硬币半径为r,初始位置为x,y,速度矢量为vx,vy,有一个圆形区域(圆心在原点)半径为R,还有一个圆盘(圆心在原点)半径为Rm (Rm < R),圆盘固定不动,硬 ...

随机推荐

  1. leetcode第一刷_Merge Sorted Array

    水题,只是思想还是实用的. 当然能够新建出一个数组.比較着拷贝过去.可是没有必要啊亲.想想为什么用源数组会麻烦,由于确定了前面的数.为了后面的数字不被覆盖,要依次往后移,转念一想,先确定后面的数字.就 ...

  2. crm操作观点

    using System;     using Microsoft.Xrm.Sdk;     using Microsoft.Crm.Sdk.Messages; /// <summary> ...

  3. CSS——(2)与标准流盒模型

    部分博客<CSS--(1)基础>中简介了CSS的概念和几种用法,如今主要是介绍其的核心内容. 盒子模型 为了理解盒子模型,我们能够先从生活中的盒子入手.盒子是用来放置物品的,内部除了有物品 ...

  4. KindEditor参数具体解释

    width 编辑器的宽度.能够设置px或%.比textarea输入框样式表宽度优先度高. 数据类型: String 默认值: textarea输入框的宽度 演示样例: K.create('#id',  ...

  5. MongoDB(三)——CRUD

    MongoDB作为非关系型数据库.还是传统数据库的增删改查有很大的差别的.这里仅仅是将知识点进行了一下提纲挈领,实际用的时候.我们百度一下具体使用方法就可以. 先看大的几个方面: 一.对于里边的插入和 ...

  6. hdu 4912 Paths on the tree(树链拆分+贪婪)

    题目链接:hdu 4912 Paths on the tree 题目大意:给定一棵树,和若干个通道.要求尽量选出多的通道,而且两两通道不想交. 解题思路:用树链剖分求LCA,然后依据通道两端节点的LC ...

  7. poj3281-Dining ,最大流量,内置图

    id=3281">点击打开链接 分析: 求最大流 建图: 拆点 牛拆成左边与食物相连的左牛 和 右边与饮料相连的右牛 1.s->食物 连边 2.食物->左牛 3.左牛-&g ...

  8. FZU 1686 龙之谜 重复覆盖

    兑换0,1模型,如.注意,数据的范围 #include <stdio.h> #include <string.h> #include <iostream> #inc ...

  9. 开玩笑html5(五岁以下儿童)---绕地球月球,地球绕太阳运动(canvas实现,同样可以移动哦)

    请珍惜劳动小编成果,这篇文章是原来小编,转载请注明出处. 速度的參数与真实速度有点差距.大家能够自行调整 <!DOCTYPE html> <html> <head> ...

  10. UVA10375 Choose and divide 质因数分解

    质因数分解: Choose and divide Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %l ...