d827: 買鉛筆

題目:http://zerojudge.tw/ShowProblem?problemid=d827
程式碼:

package zerojudge;
import java.util.Scanner;
public class d827 {

 public static void main(String[] args) {
  // TODO Auto-generated method stub
  Scanner sc = new Scanner(System.in);
  while(sc.hasNext()){
   int n = sc.nextInt();//人數
   int a = 0,b = 0;
   a = n / 12;
   a = a * 50;//一打50元
   b = n % 12;
   b = b * 5;//一支5元
   System.out.println(a+b);
  }

 }

}

留言

熱門文章