CP friends (100 Marks)
There are 3 friends who are trying to solve N problems. If anyone of them can solve the problem successfully then he will be represented by 1 else 0.
There is one more condition that they will implement the ith problem only when atleast 2 of them will be able to solve the problem, otherwise they will not be able to solve the ith problem.
You need to output the number of problems they can solve.
Input Format
First line of input consists of a single integer N, number of problems.
Next N lines each consists of three space-separated integers, representing if the problem is solvable by the person or not. Each integer is either 0 or 1.
Constraints
1<=N<=10000
Output Format
Output the number of problems they can solve.
Sample TestCase 1
Input
5
0 0 1
1 1 1
0 0 1
1 1 0
1 0 0
write a ajavascript program
Answers
Answered by
3
ans given in java
Explanation:
ughuug
Answered by
4
program to find the number of problems they can solve.
Explanation:
- Given that, There are 3 friends who are trying to solve N problems. If anyone of them can solve the problem successfully then he will be represented by 1 else 0.
- they will implement the ith issue only when atleast 2 of them will be able to solve the problem, otherwise they will not be able to solve the ith problem.
program for the number of problems they can solve:
var n = window.prompt()
var total_count = 0;
for(let i=0; i<n; i++){
var count = 0;
var t = window.prompt()
for(let j=0; j<5; j+=2){
if(t[j]=="1"){count++;}
}
if(count >=2){total_count++;}
}
hence, this is the required program to find the number of problems they can solve.
Similar questions