201709-1 打酱油 Java

思路:
先看能不能买5瓶,因为送的最多,然后看能不能买3瓶,最后一瓶一瓶地买

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int count = 0;
		if(N/50 > 0) {
			count += (N/50)*7;
			N = N % 50;
		}
		if(N/30 > 0) {
			count += (N/30)*4;
			N = N % 30;
		}
		if(N > 0) {
			count += N/10;
		}
		sc.close();
		System.out.println(count);
	}

}

posted @ 2020-02-27 09:27  菜鸡A  阅读(111)  评论(0编辑  收藏  举报