1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import java.util.Scanner; /** * UVA10056 */ public class UVA10056 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int time = sc.nextInt(); for (int i = 0; i < time; i++) { double n1 = sc.nextDouble(); double p = sc.nextDouble(); double n2 = sc.nextDouble(); System.out.printf("%.4f\r\n", p == 0 ? p : p * Math.pow(1 - p, n2 - 1) / (1 - Math.pow(1 - p, n1))); } sc.close(); } } |