// 打酱油
import java.util.Scanner;
public class 打酱油 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int n = input.nextInt(); // 小明的钱
int five_two = n / 50; // 买5送2 一次买7瓶
int three_one = (n % 50) / 30; // 买3送1 一次买4瓶
int ten_zero= ((n % 50) % 30) / 10; // 买1 一次买一瓶
int num = five_two * 7 + three_one * 4 + ten_zero;
System.out.print(num);
}
}
CCF-CSP-201709-1-打酱油 JAVA
最新推荐文章于 2026-01-08 22:28:34 发布
本文通过一个具体的Java程序示例,解析了一种购物优惠算法的实现逻辑。该算法结合了不同的优惠策略,如买5送2、买3送1和买1送0,来计算顾客在特定预算下能获得的商品数量。通过对输入金额进行分解,程序巧妙地运用了数学运算,实现了最优商品数量的计算。

2774

被折叠的 条评论
为什么被折叠?



