Skip to content

Instantly share code, notes, and snippets.

@peter279k
Created December 22, 2015 02:02
Show Gist options
  • Save peter279k/0b037d63ae08d33f1268 to your computer and use it in GitHub Desktop.
Save peter279k/0b037d63ae08d33f1268 to your computer and use it in GitHub Desktop.
import java.util.*;
public class main{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int num = input.nextInt();
for(int j=1;j<=num;j++) {
int n = input.nextInt();
double p = input.nextDouble();
int i = input.nextInt();
if(p == 0.000) {
System.out.println("0.0000");
}
else {
double result = p * Math.pow(1-p, i-1) / (1 - Math.pow(1-p, n));
System.out.printf("%.4f\r\n", result);
}
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment