zoukankan      html  css  js  c++  java
  • UESTC 1706 Orbital

    先不考虑反弹的问题,假设平面是有无数个5*10的矩形组成的,那么子弹最终会停在某个矩形之中

    而虚拟的子弹在这个矩形中的位置和真实的子弹在原矩形中的位置明显是有关系的,至于什么关系只要这个虚拟的子弹穿过了几次边界就行了

    每穿过偶次数左(或右)边界,子弹的相对位置是一样的,奇数次的话就是对称,上边界同理。

    //#pragma comment(linker, "/STACK:1024000000,1024000000")
    #include<cstdio>
    #include<cstring>
    #include<cstdlib>
    #include<algorithm>
    #include<iostream>
    #include<sstream>
    #include<cmath>
    #include<climits>
    #include<string>
    #include<map>
    #include<queue>
    #include<vector>
    #include<stack>
    #include<set>
    using namespace std;
    typedef long long ll;
    typedef pair<int,int> pii;
    #define pb(a) push_back(a)
    #define INF 0x1f1f1f1f
    #define lson idx<<1,l,mid
    #define rson idx<<1|1,mid+1,r
    #define PI  3.1415926535898
    template<class T> T min(const T& a,const T& b,const T& c) {
        return min(min(a,b),min(a,c));
    }
    template<class T> T max(const T& a,const T& b,const T& c) {
        return max(max(a,b),max(a,c));
    }
    #define clr0(a) memset(a,0,sizeof(a))
    #define clr1(a) memset(a,-1,sizeof(a))
    void debug(){
    #ifdef ONLINE_JUDGE
    #else
        freopen("d:\in.txt","r",stdin);
       // freopen("d:\out1.txt","w",stdout);
    #endif
    }
    int getch()
    {
        int ch;
    //    while((ch=getchar())!=EOF)
    //    {
    //        if(ch!=' '&&ch!='
    ')return ch;
    //    }
        scanf(" %c",&ch);
        return ch;
    }
    int main()
    {
        int t;
        scanf("%d",&t);
        for(int ca=1;ca<=t;ca++)
        {
            double d,x,y;
            scanf("%lf%lf%lf",&d,&x,&y);
            double r=sqrt((d*d)/((x-2.5)*(x-2.5)+y*y));
            double vx=r*(x-2.5),vy=r*y;
            double x0,y0;
            x0=vx+2.5;y0=vy;
            if(x0>5)
            {
                int num=0;
                while(x0>5)
                {
                    x0-=5;num++;
                }
                if(num%2==1)
                {
                    x0=5-x0;
                }
            }else if(x0<0)
            {
                int num=0;
                while(x0<0)
                {
                    x0+=5;num++;
                }
                if(num%2==1)
    
                    x0=5-x0;
            }
            if(y0>10)
            {
                int num=0;
                while(y0>10)
                {
                    y0-=10;num++;
                }
                if(num%2==1)
                    y0=10-y0;
                else
                {
                    printf("-1
    ");continue;
                }
            }
            double rr=min(x0-0,5-x0);
            rr=min(rr,y0,10-y0);
            printf("%.3lf %.3lf %.3lf
    ",x0,y0,rr);
        }
        return 0;
    }
    View Code
  • 相关阅读:
    新的知识点来了-ES6 Proxy代理 和 去银行存款有什么关系?
    JavaScript中一种全新的数据类型-symbol
    箭头函数的this指向问题-一看就懂
    ES6中对函数的扩展
    ES6中对象的扩展
    ES6中对数组的扩展
    ES6中对数值的扩展
    UWP --- Display Content 显示基础内容
    ViewBag & ViewData
    Bubble Sort冒泡排序
  • 原文地址:https://www.cnblogs.com/BMan/p/3272314.html
Copyright © 2011-2022 走看看