There are 'N' number of houses in a village. Each house requires a voltage of 'V' volts of electricity to power up their home appliances. In this context, the houses are arranged in the form of a matrix(rows*columns) where 'N' is the order of the matrix. The amount of voltage supplied to each house is calculated as current(i) resistance(r) where is the row number and 'r' is the column number. When the voltage supplied to the house(i*r) matches the value V, the appliances in the house can work. The task here is to find the number of houses whose voltage value(i*r) is the same as V. If hone of the house's value matches display a message "NO POWER".
Answers
Answered by
0
Answer:
hai u can do it on ur own try it
Answered by
0
Answer:
import java.util.*;
class Solution
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int v=sc.nextInt();
int count=0;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
if(i*j==v)
count++;
}
if(count==0)
System.out.println("NO POWER");
else
System.out.println(count);
}
}
Similar questions