题解 | #数列的和#

数列的和

http://www.nowcoder.com/practice/fe19f8a78a5148018f4be53ae9b5e11e

写个能看的懂得吧!!!

import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            double n = sc.nextDouble();
            int m = sc.nextInt();
            double ans = 0;
            for (int i = 0; i < m; i++) {
                ans += n;
                n = Math.sqrt(n);
            }
            System.out.printf("%.2f",ans);
            System.out.println();
        }
    }
}
全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务