[Plain] Description
We know that f [] and g [] are two integer arrays, and the elements are sorted in ascending order. Please write a program to calculate the logarithm of f [] greater than the element in g. In other words, f [0] is bigger than how many elements in g [], and f [1] is bigger than how many elements in g []. The sum of these values is the answer.
For example, if f [] contains 1, 3, 5, 7, 9, and g [] contains 2, 3, 4, 7, and 8.
So:
F [0] is smaller than all elements in g;
F [1] is larger than g [0;
F [2] is larger than g [0], g [1], and g [2;
F [3] is larger than g [0], g [1], and g [2;
F [4] is larger than g [0], g [1], g [2], g [3], and g [4;
So the answer is 0 + 1 + 3 + 3 + 5 = 12.
Input
The first behavior is two integers, m, n (1 ≤ m, n ≤ 1000), representing the length of the array f [], g [], respectively.
The second row has m elements, which are arrays f [].
The third row has n elements, which are array g [].
Output
Output Control Value.
Sample Input
5 5
1 3 5 7 9
2 3 4 7 8
Sample Output
12
Description
We know that f [] and g [] are two integer arrays, and the elements are sorted in ascending order. Please write a program to calculate the logarithm of f [] greater than the element in g. In other words, f [0] is bigger than how many elements in g [], and f [1] is bigger than how many elements in g []. The sum of these values is the answer.
For example, if f [] contains 1, 3, 5, 7, 9, and g [] contains 2, 3, 4, 7, and 8.
So:
F [0] is smaller than all elements in g;
F [1] is larger than g [0;
F [2] is larger than g [0], g [1], and g [2;
F [3] is larger than g [0], g [1], and g [2;
F [4] is larger than g [0], g [1], g [2], g [3], and g [4;
So the answer is 0 + 1 + 3 + 3 + 5 = 12.
Input
The first behavior is two integers, m, n (1 ≤ m, n ≤ 1000), representing the length of the array f [], g [], respectively.
The second row has m elements, which are arrays f [].
The third row has n elements, which are array g [].
Output
Output Control Value.
Sample Input
5 5
1 3 5 7 9
2 3 4 7 8
Sample Output
12
[Plain] # include <stdio. h>
Int main ()
{
Int I;
Int j;
Int n;
Int m;
Int sum;
Int f [1001];
Int g [1001];
Scanf ("% d", & n, & m );
Sum = 0;
For (I = 0; I <n; I ++)
{
Scanf ("% d", & f [I]);
}
For (j = 0; j <m; j ++)
{
Scanf ("% d", & g [j]);
}
For (I = 0; I <n; I ++)
{
For (j = 0; j <m; j ++)
{
If (f [I]> g [j])
{
Sum ++;
}
Else
{
Break;
}
}
}
Printf ("% d \ n", sum );
Return 0;
}
# Include <stdio. h>
Int main ()
{
Int I;
Int j;
Int n;
Int m;
Int sum;
Int f [1001];
Int g [1001];
Scanf ("% d", & n, & m );
Sum = 0;
For (I = 0; I <n; I ++)
{
Scanf ("% d", & f [I]);
}
For (j = 0; j <m; j ++)
{
Scanf ("% d", & g [j]);
}
For (I = 0; I <n; I ++)
{
For (j = 0; j <m; j ++)
{
If (f [I]> g [j])
{
Sum ++;
}
Else
{
Break;
}
}
}
Printf ("% d \ n", sum );
Return 0;
}