Objective In this challenge, we're going to use loops to help us do some simple math. Task Given an integer, , print its first multiples. Each multiple (where ) should be printed on a new line in the form: N x i = result . Input Format A single integer, . Constraints Output Format Print lines of output; each line (where ) contains the of in the form: N x i = result . Sample Input 2 Sample Output 2 x 1 = 2 2 x 2 = 4 2 x 3 = 6 2 x 4 = 8 2 x 5 = 10 2 x 6 = 12 2 x 7 = 14 2 x 8 = 16 2 x 9 = 18 2 x 10 = 20 Explanation: Here, we just need to use for loops to achieve the result Solution : import java.io.* ; import java.math.* ; import java.security.* ; import java.text.* ; import java.util.* ; import java.util.concurrent.* ; import java.util.regex.* ; public class Solution { public static void main ( String [] args ) throws IOException { BufferedReader bufferedReader = new BufferedReader ( new InputStreamReader ( Syste
One day Bob is playing Zombie World video game. In Zombie World game each round will contain N zombie's and each zombie's energy is Zi (where 1<=i<=N). Bob will start the round with B energy. In order to move to the next level Bob need to kill all the N zombie's but Bob can select any one among N Zombie's. If energy of Bob (B) is less than Zombie energy (Zi) then Bob will die and lose the round else Bob will won, during the fighting with zombie, Bob will lose his energy by (Zi%2)+(Zi/2). At any point of game Bob will play optimally. Now your task is to find out whether Bob can reach to the next level or not.
Input Format:
First line will contains B and N, separated by space, where B is the energy of Bob and N is the number of Zombie. Next line will contain N spaced integers each will represent the energy of zombie.
Line 1
B N, where B is the energy of Bob and N is the number of Zombie
Line 2
Zi, where Zi is a list containing energy of zombies separated by space.
Constraints:
Input Format:
First line will contains B and N, separated by space, where B is the energy of Bob and N is the number of Zombie. Next line will contain N spaced integers each will represent the energy of zombie.
Line 1
B N, where B is the energy of Bob and N is the number of Zombie
Line 2
Zi, where Zi is a list containing energy of zombies separated by space.
Constraints:
1<=N<=10^4
1<=B<=10^9
1<=Zi<=10^5
Note:
for this problem all the divisions are integer divisions.
Output Format:
Print "YES" or "NO" depending upon whether Bob can reach the next level or not.
Input
35 3
5 9 6
1<=B<=10^9
1<=Zi<=10^5
Note:
for this problem all the divisions are integer divisions.
Output Format:
Print "YES" or "NO" depending upon whether Bob can reach the next level or not.
Input
35 3
5 9 6
YES
Logic:
- Input for Energies and No.of.Zombies.
- List for Zombies Energies
- Find the sum of energiees needed using given formula
- If Energies>=s:print Yes
- else NO
Program:
Comments
Post a Comment