Solve the mystery.
Input :
First line contains T - No. of test cases.
For each test case there are two lines.
first line contains N.
Second line contains N space separated integers A[1] to A[N].
Output :
Print answer of the mystery in separate lines.
Constraints :
1<=T<=10
1<= N <= 10^5
0<= A[i] <= 10^5
Sample Input(Plaintext Link)
6
3
2 2 2
3
1 2 3
5
2 2 3 3 4
5
1 2 3 4 5
4
2 4 5 6
6
1 2 3 1 2 3
Sample Output(Plaintext Link)
0
4
6
9
5
8
Solution-:
.#include<stdio.h>
Input :
First line contains T - No. of test cases.
For each test case there are two lines.
first line contains N.
Second line contains N space separated integers A[1] to A[N].
Output :
Print answer of the mystery in separate lines.
Constraints :
1<=T<=10
1<= N <= 10^5
0<= A[i] <= 10^5
Sample Input(Plaintext Link)
6
3
2 2 2
3
1 2 3
5
2 2 3 3 4
5
1 2 3 4 5
4
2 4 5 6
6
1 2 3 1 2 3
Sample Output(Plaintext Link)
0
4
6
9
5
8
Solution-:
.#include<stdio.h>
int main()
{
int i,j,n,a,sum,b;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a);
sum=0;
for(j=0;j<a;j++)
{scanf("%d",&b);
if(b%2==0){}
else
sum=sum+b;
}
printf("%d",sum);
}}
Consider a matrix M of integers. Divide M into 4 sub-matrices. These sub-matrices are called as Quadrants. Report the Quadrant number which has the smallest minimum-element. If two or more quadrants have same smallest minimum, report the smallest quadrant index.
ReplyDeleteThe matrix M is divided into four quadrants by halving the rows and columns. If row/column is an odd number, divide them in such a way that the first half of the row/column should be one smaller than the second half.
The four quadrants are numbered from 1 to 4 in the structure shown below:
Q1 | Q2
---+---
Q3 | Q4 please find solution for this