2016年1月13日 星期三

a148: You Cannot Pass?!

內容 :
你考了 n 科筆試題目,每科的滿分都是 100 分。老師說,如果平均大於 59 你就過關了。
輸入說明 : 
輸入第一行為一個數字 n,接著有 n 個正整數。
輸出說明 : 
若你被當了,請輸出「yes」,否則輸出「no」。
範例輸入 : help
1 60
3 0 80 75
5 61 61 61 61 55
範例輸出:
no
yes
no
提示 : 
標籤:

import java.util.Scanner;
public class a148 {
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);    
        while(sc.hasNext()){
               int n=sc.nextInt();
               int[] m=new int[n];
               double total=0.0;
               for(int i=0;i<n;i++){
              m[i]=sc.nextInt();
              total+=m[i];
               }
               if(Math.ceil(total/n)>=60.0)
              System.out.println("no");
               else 
              System.out.println("yes");                             
        }
}
}

沒有留言:

張貼留言