当前位置:网站首页>OJ daily practice - class dining

OJ daily practice - class dining

2022-06-22 23:33:00 KJ. JK

Problem description :

There are N Three students went to the same fast food restaurant for dinner , The fast food restaurant offers a set meal for three 90 element , Double package 70 element , Single package 40 element . What is the minimum cost for the whole class ?

For example, if there is only 1 people , Then the minimum cost of eating is 40 element ; But if there is 7 people , You can order 2 Set meal for three , Add 1 Single set meal , common 220 element .

Input
The first 1 Line an integer M, There are... Below M(0 < M <= 100) Case .

Next there is M That's ok , One integer per row N(0 < N <= 100), There are... In the class N A classmate .

Output
For each case , Output the minimum meal cost of the whole class .

Examples

Input
2
1
7

Output
40
220


Java Code :

import java.util.Scanner; 
public class Main {
     
    public static void main(String[] args) {
     
        Scanner sc = new Scanner(System.in); 
        int num = sc.nextInt(); 
        for (int i = 0; i < num; i++) {
    
            int n = sc.nextInt(); 
            if (n % 3 == 0) {
     
                System.out.println((n / 3) * 90); 
            } else if (n % 3 == 2) {
     
                System.out.println((n / 3) * 90 + 70); 
            } 
            else if (n % 3 == 1) 
            {
     System.out.println((n / 3) * 90 + 40); } } } }

author :KJ.JK
If the article is helpful to you , Welcome to praise or star, Your support is the greatest encouragement to the author , The shortcomings can be corrected in the comments section , Communication and learning

原网站

版权声明
本文为[KJ. JK]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/173/202206222059454433.html