1. 程式人生 > >ACM-ICPC 長沙現場賽 C 題 ZOJ3728(為什麼我A過的數學題都是水題T_T)

ACM-ICPC 長沙現場賽 C 題 ZOJ3728(為什麼我A過的數學題都是水題T_T)

Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge

There's a round medal fixed on an ideal smooth table, Fancy is trying to throw some coins and make them slip towards the medal to collide. There's also a round range which shares exact the same center as the round medal, and radius of the medal is strictly less than radius of the round range. Since that the round medal is fixed and the coin is a piece of solid metal, we can assume that energy of the coin will not lose, the coin will collide and then moving as reflect.

Now assume that the center of the round medal and the round range is origin ( Namely (0, 0) ) and the coin's initial position is strictly outside the round range. Given radius of the medal Rm, radius of coin r, radius of the round range R, initial position (xy) and initial speed vector (vxvy) of the coin, please calculate the total time that any part of the coin is inside the round range.

Please note that the coin might not even touch the medal or slip through the round range.

Input

There will be several test cases. Each test case contains 7 integers RmRrxyvx and vy in one line. Here 1 ≤ Rm < R ≤ 2000, 1 ≤ r ≤ 1000, R + r < |(xy)| ≤ 20000, 1 ≤ |(vxvy)| ≤ 100.

Output

For each test case, please calculate the total time that any part of the coin is inside the round range. Please output the time in one line, an absolute error not more than 1e-3 is acceptable.

Sample Input

5 20 1 0 100 0 -1
5 20 1 30 15 -1 0

Sample Output

30.000
29.394
大意 就是用半徑為r的硬幣去碰Rm的金牌,問在R範圍內的時長。
本體的重點有三:1,硬幣的半徑處理,我是直接加到了Rm和R的上,然後硬幣就成了點。
2,情況討論,用直線到原點距離分成三種
3,就是判斷方向了,方向不對直接0
程式碼如下:
#pragma comment(linker, "/STACK:102400000,102400000")
#include "iostream"
#include "cstring"
#include "algorithm"
#include "cmath"
#include "cstdio"
#include "sstream"
#include "queue"
#include "vector"
#include "string"
#include "stack"
#include "cstdlib"
#include "deque"
#include "fstream"
#include "map"
using namespace std;
typedef long long LL;
const int INF = 0x1fffffff;
const int MAXN = 1000;
#define eps 1e-14
const int mod = 100000007;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1


double dis(int x,int y,int vx,int vy)
{
    return (double)abs(vx*y-vy*x)/sqrt(vx*vx+vy*vy);
}


int main()
{
    //freopen("in","r",stdin);
    //freopen("out","w",stdout);
    int Rm,R,r,x,y,vx,vy;
    while (scanf("%d%d%d%d%d%d%d",&Rm,&R,&r,&x,&y,&vx,&vy)!=EOF)
    {
        double dis0=sqrt(x*x+y*y);
        double y1=y+vy/1000.0;
        double x1=x+vx/1000.0;
        if (sqrt(x1*x1+y1*y1)>dis0) printf("0.000\n");//判斷方向
        else
        {
            double l=dis(x,y,vx,vy);
            double v=sqrt(vx*vx+vy*vy);
            //cout<<l<<endl;
            Rm+=r;
            R+=r;
            if (l>=R) printf("0.000\n");//第一種未經過
            else
            {
                double s0=2*sqrt(R*R-l*l);
                if (l>=Rm)
                    printf("%.3lf\n",s0/v);//第二種直接穿過
                else
                {
                    double s1=s0-2*sqrt(Rm*Rm-l*l);//第三種碰撞發生
                    printf("%.3lf\n",s1/v);
                }
            }
        }
    }
}

相關推薦

ACM-ICPC 長沙現場 C ZOJ3728為什麼A數學題都是水T_T

Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge There's a round medal fixed on an ideal smooth table, Fancy is tryi

2017 ACM-ICPC西安現場 JLOL暴力

題意:輸入五個長度為100的01串,從每個串中選擇一個是1的位置,任意兩個串中選擇的位置不能相同,一共有多少種情況,答案乘以常數531192758再對1e9+7取模。 如果對五個串都dfs複雜度是10^10穩T,所以對前四個串dfs,最後一個串的貢獻直接加到最終的答案上。

2018年ACM-ICPC 南京現場 A.Adrien and Austin

題意 有一堆數量為N的石子,石子編號從1⋯N1\cdots N1⋯N排成一列,兩個人玩遊戲,每次可以取1⋯K1\cdots K1⋯K個連續編號的石子,Adrien先手,如果有誰不能取了則他輸,兩個人為A

2018 ACM-ICPC 瀋陽網路C Convex hull

考慮杜教篩就跑偏了… 定義gay(i)=i2∗μ2(i)gay(i)=i2∗μ2(i) ∑ni=1∑ij=1gay(i)=∑ni=1(n−i+1)gay(i)=∑ni=1(n−i+1)i2μ2(i)∑i=1n∑j=1igay(i)=∑i=1n(n−i+1

The 2018 ACM-ICPC上海大都會 J Beautiful Numbers 數位DP

mes div spa ems urn 余數 limit style 狀態 題意:求小於等於N且能被自己所有位上數之和整除的數的個數。 分析:裸的數位dp。用一個三位數組dp[i][j][k]記錄:第i位,之前數位之和為j,對某個mod余數為k的狀態下滿足條件的個數。這裏m

2018 ACM-ICPC南京網路 Magical Girl Haze分層最短路

There are NN cities in the country, and MM directional roads from uu to v(1\le u, v\le n)v(1≤u,v≤n). Every road has a distance c_ici​. Haz

2018 ACM-ICPC 亞洲區域北京現場 I

做法:打表找規律 大數是過不了這個題的(但可以用來打表) 先找k的字首,字首對應邊緣數字是哪個 如果第0位是2-9 對應奇數長度的1-8 第0位為1時,第1位為0時對應奇數長度的9,為1-9時對應偶數長度的1-9,剩下的根據奇偶判斷先從頭到尾再從尾到頭跑一編即可 如100會得到909 100234會得

2018年 ACM/ICPC亞洲區域 青島賽區現場 FZOJ 4063 思維

DreamGrid, the king of Gridland, is making a knight tournament. There are  knights, numbered from 1 to , participating in the tournamen

hdu 5950 2016ACM/ICPC瀋陽賽區現場C【矩陣快速冪】

Problem Description Farmer John likes to play mathematics games with his N cows. Recently, they are attracted by recursive seque

2018 ACM-ICPC 亞洲區域青島站 C-Flippy Sequence計數

  思路來源 https://blog.csdn.net/Game_Acm/article/details/83745455 題意 給兩個01串A串和B串,在A串中可以進行區間翻轉操作,可以使得一個區間內所有的0變成1,所有的1變成0,求恰好翻轉兩次使得A

ACM-ICPC 2018 瀋陽網路 C Convex Hull 莫比烏斯+容斥

long long 爆的我心痛,現在編譯器都支援128位的了。。。 神奇,電腦編譯器都過不了(老了),交上去ac了,就是複雜度還有點高,應該不是正解,不過又get到了新知識, 不過也有的巨佬說是餘數太大的緣故,所以中間採用 int128 很菜,容斥推導那塊想了半天才

2015ACM/ICPC 北京賽區現場C 【bfs】

題意: 將字串2變成字串1,有兩種改變方法 1.將所有的同一字元換成另一種字元,只需要一步 2.將一個字母換成另一個字母,只需要一步 求出最少的改變次數 分析: 先bfs只進行第一種操作的所有可能方案,之後只進行2操作 程式碼: #includ

2015 ACM/ICPC 北京區域 現場 D—Kejin Game【網路流】

題意: 題意:給一顆有向樹,技能獲得的前提是他的前置技能都獲得了,作為一個玩家,你有特權: 1.直接花費一定數量的錢獲得某個技能。 2.花費一定數量的錢將一個技能的某一個前置關係取消,即將前置技能到該技能的邊消除(不需要獲得前置技能)。 如果正常學習技能的話

2015 ACM/ICPC 瀋陽區域 現場 M—Meeting 【Dijkstra】

題意: 給你n(n<=1e5)個點,m個關係:每個關係代表一個集合,包含權值v,表示該集合集合中兩兩的距離,還有集合的點的個數cnt和集合裡的點的標號,相當於一個有距離的完全圖。 保證集合中所有的點的數量不超過1e6。 兩個人分別從1點和n點走,只可以

2018年 ACM/ICPC亞洲區域 青島賽區現場 比賽總結

首先祝賀自己收穫了ACM生涯中的第二枚銅牌。 首先吐槽一下中石油: 週六早上來到中國石油大學,連個志願者小姐姐都沒看到。(但是看到了女裝大佬)。報完到之後發現教練少了一張午餐券(要不要這麼粗心)。為了睡覺就在肯德基吃了午飯(看到了不錯的小姐姐),然後回賓館睡了一會兒(賓館

第 43 屆 ACM-ICPC 亞洲區域徐州現場名額分配規則及相關說明

2018 年第 43 屆 ACM-ICPC 亞洲區域賽(徐州),將於 2018 年 10 月 27-28 日 在中國礦業大學舉辦現場賽,現將現場賽名額分配相關資訊釋出如下:   1.徐州站網路賽學校排名前 120 名的高校獲得 1 個現場賽名額;  2.參加過徐州全國邀請賽

2016 acm/icpc 青島網路 題解hdu 5878-5889,9道

5878.I Count Two Three(打表預處理,二分) 題目大意:有一些數可以寫成2a3b5c7d的形式,稱之為”I count two three numbers”.輸入一個數,問比他大的最小的”I count two three number

2013 ACM/ICPC 長沙賽區湖大全國邀請賽 A(6.1修訂)

小記:這次大賽教訓慘重,ACM的路任重道遠,現在努力做出每道題的解題報告吧。以此來撫慰我那慘痛的心靈。 題目: 這個題目名叫So easy!  當初看了 就想A, 現在看來這估計就是個陷阱,數學不好的必被坑。 由於我是用word寫好的,但是裡面的數學符號複製不出來,

2018ACM-ICPC南京現場D Country Meow

2018ACM-ICPC南京現場賽D題-Country Meow Problem D. Country Meow Input file: standard input Output file: standard output In the 24th century, there is a country so

2017 ACM區域現場 青島站 E polya計數

amp mod 循環 等價 img cout es2017 範圍 知乎 題目鏈接(暫無) 吐槽:這場比賽感覺對我感覺還算友好,雖然Q群知乎上命題方已經被噴死了,C語言上機題還有字符串題有大腿隊友輕松搞定,網絡流恰是我能想出來的,E本來也應該是在能力範圍內,不過因為之前沒寫過