A Most Ingenious Pair a' Twins
Jump to navigation
Jump to search
Introduction
This asks you to plug numbers into an equation and get the result.
Solutions
Idea
Do some basic algebra, and compute the desired result.
Gotchas
be sure to use %.3f to print to three places
Code
Solution - Java
import java.util.*;
public class a {
Scanner in=new Scanner(System.in);
public static void main(String[] args) {
new a().go();
}
private void go() {
while(true){
double te=in.nextDouble(),tr=in.nextDouble();
if(te==0&&tr==0)break;
System.out.printf("%.3f\n", Math.sqrt((1-tr/te*tr/te)));
}
}
}