hdu_2009 求数列的和

来源:互联网 发布:一龙恒业 安东 知乎 编辑:程序博客网 时间:2024/06/15 04:12
import java.text.DecimalFormat;import java.util.Scanner;/** * Created by feyman1120 on 2017/11/23. */public class Main {    public static void main(String [] args){        Scanner scan = new Scanner(System.in);        while (scan.hasNext()){            int m = scan.nextInt();            int n = scan.nextInt();            double sum  = 0;            double x    = m;            for (int i = 0; i < n; ++i){                sum += x;                x = Math.sqrt(x);            }            DecimalFormat df = new DecimalFormat("#0.00");            System.out.println(df.format(sum));        }    }}