Fare丶梦


私信TA

用户名:126913199

访问量:31047

签 名:

等  级
排  名 132
经  验 4890
参赛次数 0
文章发表 50
年  龄 22
在职情况 学生
学  校
专  业

  自我简介:

TA的其他文章

import java.util.Scanner;

import java.text.DecimalFormat;


public class Main {

        public static void ball(float M,int N){

                DecimalFormat df = new DecimalFormat("0.00");

                float num = 0;//共经过多少米

                float numA = 0;//反弹多高

                if(N>=1){

                        num = M;

                       numA = M/2;

                        if(N>=2){

                                for(int i = 1;i<N;i++){

                                        num+=numA*2;

                                        numA=numA/2;

                                }

                        }

                }

                System.out.print(df.format(numA)+" "+df.format(num));

        }

        public static void main(String[] arg){

                Scanner sc = new Scanner(System.in);

                float M = sc.nextFloat();

                int N = sc.nextInt();

               ball(M, N);

        }

}


 

0.0分

0 人评分

  评论区