acm2009

/**

* 数列的和

* 数列的第一项为n,以后各项为前一项的平方根,求数列的前m项的和

*/

import java.util.Scanner;

public class acm2009 {

public static void main(String[] args) {

Scanner in = new Scanner(System.in);

while(in.hasNextInt()){

int firstNum = in.nextInt();

int lastNum = in.nextInt();

double sum= firstNum;

double tmp= firstNum;

for(int i = 0 ; i < lastNum-1 ;i++){

tmp = Math.sqrt(tmp);

sum += tmp;

}

System.out.printf("%.2f",sum);

System.out.println();

}

}

}

时间: 2024-10-13 21:56:52

acm2009的相关文章