L1-007 念数字 (10 分)
输入一个整数,输出每个数字对应的拼音。当整数为负数时,先输出fu字。十个数字对应的拼音如下:

0: ling
1: yi
2: er
3: san
4: si
5: wu
6: liu
7: qi
8: ba
9: jiu
输入格式:
输入在一行中给出一个整数,如:1234。

提示:整数包括负数、零和正数。

输出格式:
在一行中输出这个整数对应的拼音,每个数字的拼音之间用空格分开,行末没有最后的空格。如 yi er san si。

输入样例:
-600
输出样例:
fu liu ling ling

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		String a;
		Scanner scanner=new Scanner(System.in);
		a=scanner.nextLine();
		
		char[] arr = a.toCharArray();
		
		int zhi;
		
		for(int i = 0;i < arr.length;i++)
		{
			if(arr[i] == '0')
			{
				zhi = 0;
				System.out.print("ling");
			}else if(arr[i] == '1'){
				zhi = 1;
				System.out.print("yi");
			}else if(arr[i] == '2'){
				zhi = 2;
				System.out.print("er");
			}else if(arr[i] == '3'){
				zhi = 3;
				System.out.print("san");
			}else if(arr[i] == '4'){
				zhi = 4;
				System.out.print("si");
			}else if(arr[i] == '5'){
				zhi = 5;
				System.out.print("wu");
			}else if(arr[i] == '6'){
				zhi = 6;
				System.out.print("liu");
			}else if(arr[i] == '7'){
				zhi = 7;
				System.out.print("qi");
			}else if(arr[i] == '8'){
				zhi = 8;
				System.out.print("ba");
			}else if(arr[i] == '9'){
				zhi = 9;
				System.out.print("jiu");
			}else {
				System.out.print("fu");
			}
			
			if(i != (arr.length - 1))
			{
				System.out.print(" ");
			}
		}
	}
}

L1-008 求整数段和 (10 分)
给定两个整数A和B,输出从A到B的所有整数以及这些数的和。

输入格式:
输入在一行中给出2个整数A和B,其中−100≤A≤B≤100,其间以空格分隔。

输出格式:
首先顺序输出从A到B的所有整数,每5个数字占一行,每个数字占5个字符宽度,向右对齐。最后在一行中按Sum = X的格式输出全部数字的和X。

输入样例:
-3 8
输出样例:
-3 -2 -1 0 1
2 3 4 5 6
7 8
Sum = 30

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a=scanner.nextInt();
        int b=scanner.nextInt();
        int i=1;
        int sum=0;

        if(a==b){
            System.out.printf("%5d",b);
            sum=a;
        }else {
            while (a<=b){
                System.out.printf("%5d",a);
                if(i%5==0){
                  System.out.println();
                }
                i=i+1;
                sum=sum+a;
                a=a+1;
            }
        }
        System.out.printf("\nSum = %d",sum);
    }
}

L1-010 比较大小 (10 分)
本题要求将输入的任意3个整数从小到大输出。

输入格式:
输入在一行中给出3个整数,其间以空格分隔。

输出格式:
在一行中将3个整数从小到大输出,其间以“->”相连。

输入样例:
4 2 8
输出样例:
2->4->8

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int[] arr = new int[3];
		Scanner scanner=new Scanner(System.in);
		
		for(int i = 0;i<3;i++)
		{
			arr[i]=scanner.nextInt();
		}
		
		int temp;
		
		for(int i = 0;i<3 - 1;i++)
		{
			for(int j = 0;j < 3 - i -1;j++)
			{
				if(arr[j] > arr[j+1])
				{
					temp = arr[j];
					arr[j] = arr[j+1];
					arr[j+1] = temp;
				}
			}
		}
		
		for(int i = 0;i<3;i++)
		{
			System.out.print(arr[i]);
			if(i != 2)
			{
				System.out.print("->");
			}
		}
		
	}
}

L1-013 计算阶乘和 (10 分)
对于给定的正整数N,需要你计算 S=1!+2!+3!+…+N!。

输入格式:
输入在一行中给出一个不超过10的正整数N。

输出格式:
在一行中输出S的值。

输入样例:
3
输出样例:
9

public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n=scanner.nextInt();
        int sum = 0;
        for (int i=n;i>=1;i--){
            int jx = 1;
            for (int j=i;j>1;j--){
                jx = jx*j;
            }
            sum = sum + jx;
        }
        System.out.println(sum);

    }
}

L1-018 大笨钟 (10 分)
微博上有个自称“大笨钟V”的家伙,每天敲钟催促码农们爱惜身体早点睡觉。不过由于笨钟自己作息也不是很规律,所以敲钟并不定时。一般敲钟的点数是根据敲钟时间而定的,如果正好在某个整点敲,那么“当”数就等于那个整点数;如果过了整点,就敲下一个整点数。另外,虽然一天有24小时,钟却是只在后半天敲1~12下。例如在23:00敲钟,就是“当当当当当当当当当当当”,而到了23:01就会是“当当当当当当当当当当当当”。在午夜00:00到中午12:00期间(端点时间包括在内),笨钟是不敲的。

下面就请你写个程序,根据当前时间替大笨钟敲钟。

输入格式:
输入第一行按照hh:mm的格式给出当前时间。其中hh是小时,在00到23之间;mm是分钟,在00到59之间。

输出格式:
根据当前时间替大笨钟敲钟,即在一行中输出相应数量个Dang。如果不是敲钟期,则输出:

Only hh:mm. Too early to Dang.
其中hh:mm是输入的时间。

输入样例1:
19:05
输出样例1:
DangDangDangDangDangDangDangDang
输入样例2:
07:05
输出样例2:
Only 07:05. Too early to Dang.

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
          String time = scanner.next();
          String[] arr=time.split(":");
          int h = Integer.valueOf(arr[0]);
          int m = Integer.valueOf(arr[1]);
          if (h<12){
              System.out.print("Only "+time+".  Too early to Dang.");
          }else if(h==12) {
              if(m==0){
                  System.out.print("Only "+time+".  Too early to Dang.");
              }else{
                  System.out.print("Dang");
              }
          }else {
              if(m==0){
                  h=h-12;
                  for (int i=0;i<h;i++){
                      System.out.print("Dang");
                  }
              }else{
                  h=h-12+1;
                  for (int i=0;i<h;i++){
                      System.out.print("Dang");
                  }
              }
          }
   }
}

L1-022 奇偶分家 (10 分)
给定N个正整数,请统计奇数和偶数各有多少个?

输入格式:
输入第一行给出一个正整N(≤1000);第2行给出N个非负整数,以空格分隔。

输出格式:
在一行中先后输出奇数的个数、偶数的个数。中间以1个空格分隔。

输入样例:
9
88 74 101 26 15 0 34 22 77
输出样例:
3 6

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int[] array = new int[a];
        int js = 0;
        int os = 0;
        for (int i = 0; i < a; i++) {
            array[i] = scanner.nextInt();
        }
        for (int i = 0; i < a; i++) {
            if(array[i]%2==0){
                os = os + 1;
            }else{
                js = js + 1;
            }
        }
        System.out.printf("%d %d",js,os);
    }
}

L1-028 判断素数 (10 分)
本题的目标很简单,就是判断一个给定的正整数是否素数。

输入格式:
输入在第一行给出一个正整数N(≤ 10),随后N行,每行给出一个小于2
31
的需要判断的正整数。

输出格式:
对每个需要判断的正整数,如果它是素数,则在一行中输出Yes,否则输出No。

输入样例:
2
11
111
输出样例:
Yes
No

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int[] array = new int[a];
        for (int i = 0; i < a; i++) {
            array[i] = scanner.nextInt();
        }
        for (int i = 0; i < a; i++) {
            if(fun(array[i])){
                System.out.print("Yes\n");
            }else{
                System.out.print("No\n");
            }
        }
    }
    public static boolean fun(int a){
        if(a==1){
            return false;
        }else{
            for (int i = 2; i < Math.sqrt(a); i++) {
                if(a % i == 0){
                    return false;
                }
            }
        }
        return true;
    }

}

L1-031 到底是不是太胖了 (10 分)
据说一个人的标准体重应该是其身高(单位:厘米)减去100、再乘以0.9所得到的公斤数。真实体重与标准体重误差在10%以内都是完美身材(即 | 真实体重 − 标准体重 | < 标准体重×10%)。已知市斤是公斤的两倍。现给定一群人的身高和实际体重,请你告诉他们是否太胖或太瘦了。

输入格式:
输入第一行给出一个正整数N(≤ 20)。随后N行,每行给出两个整数,分别是一个人的身高H(120 < H < 200;单位:厘米)和真实体重W(50 < W ≤ 300;单位:市斤),其间以空格分隔。

输出格式:
为每个人输出一行结论:如果是完美身材,输出You are wan mei!;如果太胖了,输出You are tai pang le!;否则输出You are tai shou le!。

输入样例:
3
169 136
150 81
178 155
输出样例:
You are wan mei!
You are tai shou le!
You are tai pang le!

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int  n = scanner.nextInt();
       int[] H = new int[n];
       int[] W = new int[n];
        for (int i = 0; i < n; i++) {
            H[i] = scanner.nextInt();
            W[i] = scanner.nextInt();
        }
        for (int i = 0; i < n; i++) {
           double biao = (H[i]-100)*0.9*2;
           if(Math.abs(W[i] - biao )< biao*0.1 ){
               System.out.println("You are wan mei!");
           }else if(W[i] > biao ){
               System.out.println("You are tai pang le!");
           }else if(W[i]< biao){
               System.out.println("You are tai shou le!");
           }
        }


        }
        }

L1-037 A除以B (10 分)
真的是简单题哈 —— 给定两个绝对值不超过100的整数A和B,要求你按照“A/B=商”的格式输出结果。

输入格式:
输入在第一行给出两个整数A和B(−100≤A,B≤100),数字间以空格分隔。

输出格式:
在一行中输出结果:如果分母是正数,则输出“A/B=商”;如果分母是负数,则要用括号把分母括起来输出;如果分母为零,则输出的商应为Error。输出的商应保留小数点后2位。

输入样例1:
-1 2
输出样例1:
-1/2=-0.50
输入样例2:
1 -3
输出样例2:
1/(-3)=-0.33
输入样例3:
5 0
输出样例3:
5/0=Error

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int  a = scanner.nextInt();
        int b = scanner.nextInt();
        float c;
        c=(float) a/b;
        if (b>0){
            System.out.printf("%d/%d=%.2f",a,b,c);
        }else if (b==0){
            System.out.printf("%d/%d=Error",a,b);
        }else{
            System.out.printf("%d/(%d)=%.2f",a,b,c);
        }
    }
}

L1-040 最佳情侣身高差 (10 分)
专家通过多组情侣研究数据发现,最佳的情侣身高差遵循着一个公式:(女方的身高)×1.09 =(男方的身高)。如果符合,你俩的身高差不管是牵手、拥抱、接吻,都是最和谐的差度。

下面就请你写个程序,为任意一位用户计算他/她的情侣的最佳身高。

输入格式:
输入第一行给出正整数N(≤10),为前来查询的用户数。随后N行,每行按照“性别 身高”的格式给出前来查询的用户的性别和身高,其中“性别”为“F”表示女性、“M”表示男性;“身高”为区间 [1.0, 3.0] 之间的实数。

输出格式:
对每一个查询,在一行中为该用户计算出其情侣的最佳身高,保留小数点后2位。

输入样例:
2
M 1.75
F 1.8
输出样例:
1.61
1.96

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int  n = scanner.nextInt();
        String[]  sex = new String[n];
        Float[]   height = new Float[n];
        for (int i = 0; i < n; i++) {
            sex[i]=scanner.next();
            height[i] = scanner.nextFloat();
        }
        for (int i = 0; i < n; i++) {
            if(sex[i].charAt(0)-77==0){
                System.out.printf("%.2f\n",height[i]/1.09);
            }else if (sex[i].charAt(0)-70==0){
                System.out.printf("%.2f\n",height[i]*1.09);

            }

        }
        }
    }

L1-041 寻找250 (10 分)
对方不想和你说话,并向你扔了一串数…… 而你必须从这一串数字中找到“250”这个高大上的感人数字。

输入格式:
输入在一行中给出不知道多少个绝对值不超过1000的整数,其中保证至少存在一个“250”。

输出格式:
在一行中输出第一次出现的“250”是对方扔过来的第几个数字(计数从1开始)。题目保证输出的数字在整型范围内。

输入样例:
888 666 123 -233 250 13 250 -222
输出样例:
5

import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int t = 0;
      
        while (scanner.hasNext()){//使用hasNext()检查序列中是否还有元素。
            String s = scanner.nextLine();
            String[]  str = s.split(" ");
            int [] a = new int[str.length];
            for (int i = 0; i < str.length; i++) {
               a[i] = Integer.parseInt(str[i]);
            }
            for (int i = 0; i < str.length; i++) {
                t++;
                if(a[i]==250){
                    System.out.println(t);
                    break;
                }
            }
        }
    }
}

L1-047 装睡 (10 分)
你永远叫不醒一个装睡的人 —— 但是通过分析一个人的呼吸频率和脉搏,你可以发现谁在装睡!医生告诉我们,正常人睡眠时的呼吸频率是每分钟15-20次,脉搏是每分钟50-70次。下面给定一系列人的呼吸频率与脉搏,请你找出他们中间有可能在装睡的人,即至少一项指标不在正常范围内的人。

输入格式:
输入在第一行给出一个正整数N(≤10)。随后N行,每行给出一个人的名字(仅由英文字母组成的、长度不超过3个字符的串)、其呼吸频率和脉搏(均为不超过100的正整数)。

输出格式:
按照输入顺序检查每个人,如果其至少一项指标不在正常范围内,则输出其名字,每个名字占一行。

输入样例:
4
Amy 15 70
Tom 14 60
Joe 18 50
Zoe 21 71
输出样例:
Tom
Zoe

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        String[] name = new String[N];
        int[] hu = new int[N];
        int[] mai = new int[N];
        for (int i = 0; i < N; i++) {
            name[i] = scanner.next();
            hu[i] = scanner.nextInt();
            mai[i] = scanner.nextInt();
        }
        for (int i = 0; i < N; i++) {
            if (hu[i] >= 15 && hu[i] <= 20) {
                if (mai[i] >= 50 && mai[i] <= 70) {
                    continue;
                } else System.out.println(name[i]);
            } else System.out.println(name[i]);

        }
    }
}

L1-053 电子汪 (10 分)
据说汪星人的智商能达到人类 4 岁儿童的水平,更有些聪明汪会做加法计算。比如你在地上放两堆小球,分别有 1 只球和 2 只球,聪明汪就会用“汪!汪!汪!”表示 1 加 2 的结果是 3。

本题要求你为电子宠物汪做一个模拟程序,根据电子眼识别出的两堆小球的个数,计算出和,并且用汪星人的叫声给出答案。

输入格式:
输入在一行中给出两个 [1, 9] 区间内的正整数 A 和 B,用空格分隔。

输出格式:
在一行中输出 A + B 个Wang!。

输入样例:
2 1
输出样例:
Wang!Wang!Wang!

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
         int a = scanner.nextInt();
         int b = scanner.nextInt();
         int n = a+b;
        for (int i = 0; i < n; i++) {
            System.out.print("Wang!");
        }
    }
}

L1-055 谁是赢家 (10 分)
某电视台的娱乐节目有个表演评审环节,每次安排两位艺人表演,他们的胜负由观众投票和 3 名评委投票两部分共同决定。规则为:如果一位艺人的观众票数高,且得到至少 1 名评委的认可,该艺人就胜出;或艺人的观众票数低,但得到全部评委的认可,也可以胜出。节目保证投票的观众人数为奇数,所以不存在平票的情况。本题就请你用程序判断谁是赢家。

输入格式:
输入第一行给出 2 个不超过 1000 的正整数 Pa 和 Pb,分别是艺人 a 和艺人 b 得到的观众票数。题目保证这两个数字不相等。随后第二行给出 3 名评委的投票结果。数字 0 代表投票给 a,数字 1 代表投票给 b,其间以一个空格分隔。

输出格式:
按以下格式输出赢家:

The winner is x: P1 + P2
其中 x 是代表赢家的字母,P1 是赢家得到的观众票数,P2 是赢家得到的评委票数。

输入样例:
327 129
1 0 1
输出样例:
The winner is a: 327 + 1

public class Main {
  public static void main(String[]args) {
	  Scanner scanner = new Scanner(System.in);
	  int pa = 0;
	  int pb = 0;
	  int[] pw = new int[3];
	  pa = scanner.nextInt(); 
	  pb = scanner.nextInt(); 
	  for(int i = 0;i<=2;i++) {
		 pw[i] = scanner.nextInt();
	  }
	  
	  int pwa = 0;
	  int pwb = 0;
	  for(int i = 0;i<=2;i++) {
		  if(pw[i] == 0) {
			  pwa++;
		  }else {
			  pwb++;
		  }  
	  }
	  
	  if((pa > pb && pwa > 0)||pwa == 3) {
	    System.out.printf("The winner is a: %d + %d",pa,pwa);  
	  }else {
		System.out.printf("The winner is b: %d + %d",pb,pwb);  
	  }
  }
}

L1-061 新胖子公式 (10 分)
根据钱江晚报官方微博的报导,最新的肥胖计算方法为:体重(kg) / 身高(m) 的平方。如果超过 25,你就是胖子。于是本题就请你编写程序自动判断一个人到底算不算胖子。

输入格式:
输入在一行中给出两个正数,依次为一个人的体重(以 kg 为单位)和身高(以 m 为单位),其间以空格分隔。其中体重不超过 1000 kg,身高不超过 3.0 m。

输出格式:
首先输出将该人的体重和身高代入肥胖公式的计算结果,保留小数点后 1 位。如果这个数值大于 25,就在第二行输出 PANG,否则输出 Hai Xing。

输入样例 1:
100.1 1.74
输出样例 1:
33.1
PANG
输入样例 2:
65 1.70
输出样例 2:
22.5
Hai Xing

public class Main {
  public static void main(String[]args) {
	  Scanner input = new Scanner(System.in);
	  double biao = 0;
	  double w = input.nextDouble();
	  double h = input.nextDouble();
	  biao = w/(h*h);
	  if(biao > 25) {
		  System.out.printf("%.1f\n",biao);
		  System.out.println("PANG");	  
	  }else {
		  System.out.printf("%.1f\n",biao); 
		  System.out.println("Hai Xing");	
	  }
  }
}

L1-063 吃鱼还是吃肉 (10 分)
国家给出了 8 岁男宝宝的标准身高为 130 厘米、标准体重为 27 公斤;8 岁女宝宝的标准身高为 129 厘米、标准体重为 25 公斤。

现在你要根据小宝宝的身高体重,给出补充营养的建议。

输入格式:
输入在第一行给出一个不超过 10 的正整数 N,随后 N 行,每行给出一位宝宝的身体数据:

性别 身高 体重
其中性别是 1 表示男生,0 表示女生。身高和体重都是不超过 200 的正整数。
输出格式:
对于每一位宝宝,在一行中给出你的建议:

如果太矮了,输出:duo chi yu!(多吃鱼);
如果太瘦了,输出:duo chi rou!(多吃肉);
如果正标准,输出:wan mei!(完美);
如果太高了,输出:ni li hai!(你厉害);
如果太胖了,输出:shao chi rou!(少吃肉)。
先评价身高,再评价体重。两句话之间要有 1 个空格。

输入样例:
4
0 130 23
1 129 27
1 130 30
0 128 27
输出样例:
ni li hai! duo chi rou!
duo chi yu! wan mei!
wan mei! shao chi rou!
duo chi yu! shao chi rou!

public class Main {
  public static void main(String[]args) {
	  Scanner input = new Scanner(System.in);
	  int n = input.nextInt();
	 int[] sex = new int[n];
	 int[] h = new int[n];
	 int[] w = new int[n];
	 for(int i = 0;i < n;i++) {
		 sex[i] = input.nextInt();
		 h[i] = input.nextInt();
		 w[i] = input.nextInt();
	 }
	 for(int i = 0;i < n;i++){
		if(sex[i] == 0) {
			if(h[i] > 129) {
				System.out.print("ni li hai! ");
			}else if(h[i] == 129) {
			    System.out.print("wan mei! ");
			}else {
				System.out.print("duo chi yu! ");
			}
		    if(w[i] > 25) {
		    	System.out.print("shao chi rou!\n");
			}else if(w[i] == 25) {
				System.out.print("wan mei!\n");
			}else {
				System.out.print("duo chi rou!\n");
			}
		}else {
			if(h[i] > 130) {
				System.out.print("ni li hai! ");
			}else if(h[i] == 130) {
			    System.out.print("wan mei! ");
			}else {
				System.out.print("duo chi yu! ");
			}
		    if(w[i] > 27) {
		    	System.out.print("shao chi rou!\n");
			}else if(w[i] == 27) {
				System.out.print("wan mei!\n");
			}else {
				System.out.print("duo chi rou!\n");
			}
		}
	 }
  }
}

L1-067 洛希极限 (10 分)
科幻电影《流浪地球》中一个重要的情节是地球距离木星太近时,大气开始被木星吸走,而随着不断接近地木“刚体洛希极限”,地球面临被彻底撕碎的危险。但实际上,这个计算是错误的。

洛希极限(Roche limit)是一个天体自身的引力与第二个天体造成的潮汐力相等时的距离。当两个天体的距离少于洛希极限,天体就会倾向碎散,继而成为第二个天体的环。它以首位计算这个极限的人爱德华·洛希命名。(摘自百度百科)

大天体密度与小天体的密度的比值开 3 次方后,再乘以大天体的半径以及一个倍数(流体对应的倍数是 2.455,刚体对应的倍数是 1.26),就是洛希极限的值。例如木星与地球的密度比值开 3 次方是 0.622,如果假设地球是流体,那么洛希极限就是 0.622×2.455=1.52701 倍木星半径;但地球是刚体,对应的洛希极限是 0.622×1.26=0.78372 倍木星半径,这个距离比木星半径小,即只有当地球位于木星内部的时候才会被撕碎,换言之,就是地球不可能被撕碎。

本题就请你判断一个小天体会不会被一个大天体撕碎。

输入格式:
输入在一行中给出 3 个数字,依次为:大天体密度与小天体的密度的比值开 3 次方后计算出的值(≤1)、小天体的属性(0 表示流体、1 表示刚体)、两个天体的距离与大天体半径的比值(>1 但不超过 10)。

输出格式:
在一行中首先输出小天体的洛希极限与大天体半径的比值(输出小数点后2位);随后空一格;最后输出 _ 如果小天体不会被撕碎,否则输出 T_T。

输入样例 1:
0.622 0 1.4
输出样例 1:
1.53 T_T
输入样例 2:
0.622 1 1.4
输出样例 2:
0.78 _

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        double bi = input.nextDouble();
        int shu = input.nextInt();
        double zhi = input.nextDouble();
        double luoxi = 0;
        if(shu == 0){
            luoxi  = bi * 2.455;

        }else{
            luoxi = bi *1.26;
        }
        if (luoxi > zhi){
            System.out.printf("%.2f T_T",luoxi);
        }else{
            System.out.printf("%.2f ^_^",luoxi);
        }

    }
}

L1-068 调和平均 (10 分)
N 个正数的算数平均是这些数的和除以 N,它们的调和平均是它们倒数的算数平均的倒数。本题就请你计算给定的一系列正数的调和平均值。

输入格式:
每个输入包含 1 个测试用例。每个测试用例第 1 行给出正整数 N (≤1000);第 2 行给出 N 个正数,都在区间 [0.1,100] 内。

输出格式:
在一行中输出给定数列的调和平均值,输出小数点后2位。

输入样例:
8
10 15 12.7 0.3 4 13 1 15.6
输出样例:
1.61

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        float sum =0 ,res;
        int N = input.nextInt();
        float[] list = new float[N];

        for (int i = 0; i < N; i++) {
            list[i] = input.nextFloat();
            sum += 1.0/list[i];
        }
        res = sum/N;
        System.out.printf("%.2f",1.0/res);
    }
}