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);
    }

}

猜你喜欢

转载自www.cnblogs.com/yu-jiawei/p/12370457.html
今日推荐