Showing posts with label Volume CVII. Show all posts
Showing posts with label Volume CVII. Show all posts

Solution of 10783 - Odd Sum

Problem Description
source:https://uva.onlinejudge.org/external/107/10783.html

Given a range [a, b], you are to find the summation of all the odd integers in this range. For example, the summation of all the odd integers in the range [3, 9] is 3 + 5 + 7 + 9 = 24.

Input 

There can be at multiple test cases. The first line of input gives you the number of test cases, T (1 ≤ T ≤ 100). Then T test cases follow. Each test case consists of 2 integers a and b (0 ≤ a ≤ b ≤ 100) in two separate lines. 

image

Solution of 10773 - Back to Intermediate Math

Problem Description
source:https://uva.onlinejudge.org/external/107/10773.html

Umm! So, you claim yourself as an intelligent one? Let me check. As, computer science students always insist on optimization whenever possible, I give you an elementary problem of math to optimize. 
        You are trying to cross a river of width d meters. You are given that, the river flows at v ms−1 and you know that you can speed up the boat in u ms−1 . There may be two goals how to cross the river: One goal (called fastest path) is to cross it in fastest time, and it does not matter how far the flow of the river takes the boat. The other goal (called shortest path) is to steer the boat in a direction so that the flow of the river doesn’t take the boat away, and the boat passes the river in a line perpendicular to the boarder of the river. Is it always possible to have two different paths, one to pass at shortest time and the other at shortest path? If possible then, what is the difference (Let P s) between the times needed to cross the river in the different ways?
image