Question number: | 201709-1 |
Question name: | Soy sauce |
time limit: | 1.0s |
Memory limit: | 256.0MB |
Problem Description: | Problem Description Xiao Ming took N yuan to buy soy sauce. A bottle of soy sauce is 10 yuan, and the merchants carry out promotions, and get 1 bottle for every 3 bottles bought, or 2 bottles for every 5 bottles bought. How many bottles of soy sauce can Xiao Ming get? Input format The first line of input contains an integer N , which represents the amount of money Xiao Ming can use to buy soy sauce. N is an integer multiple of 10, and N does not exceed 300. Output format Output an integer, indicating how many bottles of soy sauce Xiao Ming can get. Sample input 40 Sample output 5 Sample description Divide 40 yuan into 30 yuan and 10 yuan, buy 3 bottles and 1 bottle respectively, of which 3 bottles get 1 bottle, and get 5 bottles in total. Sample input 80 Sample output 11 Sample description Divide 80 yuan into 30 yuan and 50 yuan, buy 3 bottles and 5 bottles respectively, of which 3 bottles get 1 bottle, 5 bottles get 2 bottles, and get 11 bottles in total. |
import java.util.Scanner;
public class 打酱油 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int count=n/10;
int t=0;
if(count>=5){
t=count%5;
count=count+2*(count/5)+t/3;
}else if(count>=3){
count=count+count/3;
}
System.out.println(count);
}
}