UVA 12230-crossing Rivers (probability)

Source: Internet
Author: User

Topic Link: UVA 12230-crossing Rivers

There is a person to go to the company every day to work. Every time it passes through N rivers. The distance between the home and the company is D. By default, the speed of the land is 1, giving information about the N River. Contains the starting coordinates p, width l, and the speed of the boat.

The boat will be back and forth on both sides of the river. People reach the riverbank is. The position of the ship is random (including direction). Ask people to reach the desired time that the company needs.

Problem-solving idea: The time on land is fixed, and it is only necessary to calculate the time of each river separately. As people arrive at the shore, the position of the ship is random, so the waiting time [0,2l/v], the period is equal probability, so the time of a river is extremely(0+ 2? L v ) 2 +l v = 2? L v

#include <cstdio>#include <cstring>#include <algorithm>using namespace STD;intMain () {intCAS =1;intNDoubleD, P, L, V; while(scanf("%D%LF", &n, &d) = =2&& (N | | D)) { for(inti =0; i < N; i++) {scanf("%LF%LF%LF", &p, &l, &v); D = D-l +2* L/V; }printf("Case%d:%.3lf\n\n", cas++, D); }return 0;}

UVA 12230-crossing Rivers (probability)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.