思考
無窮等比級數求和公式
原理: 第n項:
把S - S * r
求出:

程式碼
import java.util.Scanner;
public class main {
public static void main(String[] args) {
int num = 0;
int r = 100;
Scanner sc = new Scanner(System.in);
num = sc.nextInt();
for(int i = 0 ; i < num ; i++){
int n_count = sc.nextInt();
float percent = sc.nextFloat();
int index = sc.nextInt();
if(percent == 0){
System.out.println("0.0000");
continue;
}
float ans = (float) ((float)Math.pow(1-percent, index-1)*percent*(1-Math.pow(Math.pow(1-percent,n_count), r))/(1-Math.pow(1-percent,n_count)));
System.out.printf("%.4f", ans);
System.out.println();
}
}
}