My issue
anyone please explain this problem
My code
import java.util.*;
import java.lang.*;
import java.io.*;
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
}
}
Learning course: Prepare for your DSA interviews
Problem Link: Color the Cube Practice Problem in - CodeChef
Given six integers x_1 x_2 x_3 x_4 x_5 x_6 , you need to sum them \lceil x/2 \rceil times.
Why?
- Since the cube has 6 faces, you need to buy each x_i one litred colours to paint them. It requries half litre colour to paint one side. Hence, you can simply buy once to paint two cubes.
Code for Reference:
import java.util.*;
import java.lang.*;
import java.io.*;
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner s=new Scanner(System.in);
int t=s.nextInt();
while(t-->0){
long n=s.nextLong();
long x1=s.nextLong();
long x2=s.nextLong();
long x3=s.nextLong();
long x4=s.nextLong();
long x5=s.nextLong();
long x6=s.nextLong();
long cost=0;
cost=(x1+x2+x3+x4+x5+x6)*((n+1)/2);
System.out.println(cost);
}
}
}