BNPC-HS 2007 BABAK PENYISIHAN (PILIHAN GANDA)

Similar documents
Problem A Math for a Birthday Present

1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1

Loops / Repetition Statements

CS 6402 DESIGN AND ANALYSIS OF ALGORITHMS QUESTION BANK

Midterm CSE 21 Spring 2012

Problem A. Ascent Sequences

Thomas Jefferson Invitational Open in Informatics 2012

Sorting Pearson Education, Inc. All rights reserved.

CSE 332 Autumn 2013: Midterm Exam (closed book, closed notes, no calculators)

Priority queues. Priority queues. Priority queue operations

Computer Science 385 Analysis of Algorithms Siena College Spring Topic Notes: Introduction and Overview

COMP251: Background. Jérôme Waldispühl School of Computer Science McGill University

ACM ICPC Dhaka Regional Online Preliminary Contest th October 2018 You get 13 Pages 10 Problems

Department of Computer Applications. MCA 312: Design and Analysis of Algorithms. [Part I : Medium Answer Type Questions] UNIT I

NMC Sample Problems: Grade 8

Anti Brute Force Lock

Introduction to Algorithms I

INSTITUTE OF AERONAUTICAL ENGINEERING

CHENNAI MATHEMATICAL INSTITUTE M.Sc. / Ph.D. Programme in Computer Science

Number Theory Open, Round 1 Test #101

SET DEFINITION 1 elements members

CSCE 2014 Final Exam Spring Version A

Module 2: Classical Algorithm Design Techniques

STANDARDS OF LEARNING CONTENT REVIEW NOTES ALGEBRA I. 4 th Nine Weeks,

Data Structures and Algorithms Dr. Naveen Garg Department of Computer Science and Engineering Indian Institute of Technology, Delhi

Number System. Introduction. Natural Numbers (N) Whole Numbers (W) Integers (Z) Prime Numbers (P) Face Value. Place Value

Searching Algorithms/Time Analysis

Review Test 2. MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

September 11, Unit 2 Day 1 Notes Measures of Central Tendency.notebook

STANDARDS OF LEARNING CONTENT REVIEW NOTES. ALGEBRA I Part II. 3 rd Nine Weeks,

Solutions to In Class Problems Week 9, Fri.

CS1800 Discrete Structures Fall 2016 Profs. Aslam, Gold, Ossowski, Pavlu, & Sprague December 16, CS1800 Discrete Structures Final

MATHEMATICS FOR ELEMENTARY TEACHERS I FINAL EXAM REVIEW

FINALTERM EXAMINATION Fall 2009 CS301- Data Structures Question No: 1 ( Marks: 1 ) - Please choose one The data of the problem is of 2GB and the hard

Section A Arithmetic ( 5) Exercise A

Course Learning Outcomes for Unit I. Reading Assignment. Unit Lesson. UNIT I STUDY GUIDE Number Theory and the Real Number System

CSE 332 Winter 2015: Midterm Exam (closed book, closed notes, no calculators)

Faculty of Science FINAL EXAMINATION COMP-250 A Introduction to Computer Science School of Computer Science, McGill University

Sorting and Selection

CSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators)

ACM-ICPC Indonesia National Contest Problem A. The Best Team. Time Limit: 2s

CS-141 Final Exam Review May 16, 2015 Presented by the RIT Computer Science Community

Pseudo code of algorithms are to be read by.

SUMMER REVIEW PACKET 2 FOR STUDENTS ENTERING ALGEBRA 1

1 Probability Review. CS 124 Section #8 Hashing, Skip Lists 3/20/17. Expectation (weighted average): the expectation of a random quantity X is:

( ) n 3. n 2 ( ) D. Ο

CSC-140 Assignment 5

Practical Questions CSCA48 Winter 2018 Week 11

NMC Sample Problems: Grade 8

Pacific Northwest Region Programming Contest Division 2

MAA MD-DC-VA Section meeting, November Creative Approaches to Discrete Mathematics Brian Heinold Mount St. Mary s University

CS-141 Final Exam Review December 16, 2015 Presented by the RIT Computer Science Community

Lecture 3. Brute Force

UCS-406 (Data Structure) Lab Assignment-1 (2 weeks)

Problem Set 6 Due: 11:59 Sunday, April 29

Using Templates to Introduce Time Efficiency Analysis in an Algorithms Course

COMPUTER PROGRAMMING LAB

CS1800 Discrete Structures Fall 2016 Profs. Aslam, Gold, Ossowski, Pavlu, & Sprague December 16, CS1800 Discrete Structures Final

ACM Pacific NW Region Programming Contest 13 November 2004 Problem A: Mersenne Composite Numbers

& ( D. " mnp ' ( ) n 3. n 2. ( ) C. " n

Solved by: Syed Zain Ali Bukhari (BSCS)

Sankalchand Patel College of Engineering - Visnagar Department of Computer Engineering and Information Technology. Assignment

CSE 332 Spring 2014: Midterm Exam (closed book, closed notes, no calculators)

We've tried to include the common errors and grading standard for every question.

Data Structures and Algorithms 2018

0001 Understand the structure of numeration systems and multiple representations of numbers. Example: Factor 30 into prime factors.

TeamsCode Spring 2018 MIHS Programming Contest

EXAMINATIONS 2016 TRIMESTER 2

CSE Data Structures and Introduction to Algorithms... In Java! Instructor: Fei Wang. Mid-Term Exam. CSE2100 DS & Algorithms 1

Unit 2: Decimals. Thousands Hundreds Tens Ones Tenths Hundredths Thousandths Ten thousandths

1. One-third of 105 is the same as seven-sixths of what number? 1.

Introduction to Computer Science Unit 3. Programs

Computer Science Engineering Sample Papers

Lecture 15: Algorithms. AP Computer Science Principles

CS 161 Fall 2015 Final Exam

Lab Manual. Program Design and File Structures (P): IT-219

Integers and Rational Numbers

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

CS 2150 Final Exam, Spring 2018 Page 1 of 10 UVa userid:

CS/COE 1501 cs.pitt.edu/~bill/1501/ Introduction

Multiple-choice (35 pt.)

2017 Consortium for Computing Sciences in Colleges Programming Contest Saturday, November 4th Furman University Greenville, SC

Subject: Computer Science

Student number: Datenstrukturen & Algorithmen page 1

FINAL EXAMINATION. COMP-250: Introduction to Computer Science - Fall 2010

Algorithmic Analysis. Go go Big O(h)!

Math 155. Measures of Central Tendency Section 3.1

CS1800 Discrete Structures Fall 2017 October 25, CS1800 Discrete Structures Midterm Version B

Searching in General

1. You have a complete bipartite graph where each part contains exactly n nodes, numbered from 0 to n - 1 inclusive.

Data Structures Brett Bernstein

Prepare a stem-and-leaf graph for the following data. In your final display, you should arrange the leaves for each stem in increasing order.

CS1800 Discrete Structures Fall 2017 October 25, CS1800 Discrete Structures Midterm Version B

Give a short answer (i.e. 1 to 3 sentences) for the following questions:

Review Guide for Term Paper (Teza)

Week - 03 Lecture - 18 Recursion. For the last lecture of this week, we will look at recursive functions. (Refer Slide Time: 00:05)

UCF Practice Local Contest Aug 23, 2014

Neston High School Mathematics Faculty Homework Booklet

XVIII Open Cup named after E.V. Pankratiev Stage 1: Grand Prix of Romania, Sunday, September 17, 2017

R10 SET - 1. Code No: R II B. Tech I Semester, Supplementary Examinations, May

Transcription:

1 function f(a,b) C = 0 while B > 0 do C = C + A * (B mod 2) A = A * 2 B = B / 2 return C Let A, B, and C be integers. If A and B is natural numbers, what will function f(a,b) return? A. A power B B. Multiplication of A and B C. Greatest Common Divisor (GCD) of A and B D. Partial sum of natural number from A to B E. Least Common Multiple (LCM) of A and B 2 function f(a,b) if b = 0 then return 0 if b is odd then return f(2*a, b/2) + a return f(2*a, b/2) Let a, b, and c be integers. What is the result of f(105,27)? A. 2575 B. 2835 C. 935 D. 0 E. Error! Infinite Recursive Call 3 procedure sort(a[1..n]) for i = 1 to n - 1 do for j = 1 to n - i do if A[j] > A[j+1] then swap A[j] with A[j+1] The pseudocode above is one of the well known sorting algorithm, what is the name? A. Insertion Sort B. Quick Sort C. Selection Sort D. Bubble Sort E. Merge Sort BINUS UNIVERSITY Page 1

4 procedure sort(a[1..n]) if A <= 1 then return A Choose an element x from S Let S1 be the element of S that are smaller than x Let S2 be the element of S that are bigger x return sort(s1), S2, sort(s2) The pseudocode above is one of the well known sorting algorithm, what is the name? a. Insertion Sort b. Quick Sort c. Selection Sort d. Bubble Sort e. Merge Sort 5 What will the following function do? function f(n) if N <= 0 then return 0 return f(n-1) + N A. Factorial of N B. N-th Prime Number C. Sum of natural number up until N D. N-th even number E. Infinite loop 6 function f(n) if n = 0 then return 0 a = 0 b = 1 for i = 2 to n do c = a + b a = b b = c return b Let a, b, c, and n be integers. What will f(n) return? a. Factorial of N b. N-th Fibbonaci number c. N-th Prime number d. N-th Erdos number e. N-th Odd number BINUS UNIVERSITY Page 2

7 What this pseudocodes do? A = 83 for i = 0 to 4 do B = A XOR 1 A = A / 2 print B A. Print: 824021114 B. Print: 411214082 C. Print: 824120105 D. Print: 510204182 E. Print: 824121114 8 Look at the following pseudocode: x = 0 for i = 1 to 9 do for j = 11 to 19 do for k = 1 to 19 do x = x + 1 print x What will be printed by the pseudocode above? A. 1539 B. 729 C. 37 D. 2000 E. 1800 9 i = 0 while i < 10 do begin j = i while j < 30 do begin print j j = j + 1 end i = i + 1 end How many times j will be printed? A. 255 B. 300 C. 274 D. 275 E. 301 BINUS UNIVERSITY Page 3

10 function f(n) if n = 0 then return 1 if n mod 2 = 1 then return 2 * f(n/2) return n + 1 Let n be integer. What will f(1025) return? A. 1026 B. 513 C. 512 D. 1024 E. 1 11 function f(y,z) x = 1 while z > 0 do begin if z is odd then begin x = x * y end z = z / 2 y = y * y end return x What will f(3,4) return? A. 1 B. 9 C. 4 D. 16 E. 81 12 function f(n) if n <= 1 then return n return f(n-1) + f(n-2) How many times will the recursive function f(n) be called if it's invoked by f(8)? (including the initial call f(8)) A. 34 B. 55 C. 67 D. 68 E. 69 BINUS UNIVERSITY Page 4

13 function f(n) r = 0 for i = 1 to n do for j = 1 to i do for k = j to i + j do r = r + 1 return r What is the result of f(7)? A. 78 B. 127 C. 158 D. 168 E. 240 14 x = 0 for i = 1 to n do for j = i to n do for k = i to n do x = x + 1 print x What will be printed by the pseudocode above (n=10)? A. 275 B. 385 C. 550 D. 220 E. 285 15 S[1..5] = { 2, 4, 7, 9, 12 } function f(x,y) if y - x <= 1 then if S[x] > S[y] then return S[x] return S[y] r = (x + y) / 2 p = f(x,r) q = f(r+1,y) if p < q then return q return p What is the result of f(1,4)? BINUS UNIVERSITY Page 5

A. 2 B. 4 C. 7 D. 9 E. 12 16 x = 0 function f() x = x + 1 function g() f() f() function h() f() g() f() main() f() print x g() print x h() print x What will be printed by the pseudocode above? A. 1 3 7 B. 1 3 6 C. 0 2 6 D. 0 2 5 E. 1 2 7 17 if A AND B if (not C) OR (not D) print '1' if D print '2' print '3' if C <> D print '4' if C print '5' print '6' If A = B = C, and C = false, and A <> D, what will be printed by the pseoudocode above? BINUS UNIVERSITY Page 6

A. 2 B. 3 C. 4 D. 5 E. 6 18 The worst case complexity for Selection Sort algorithm is: A. n^3 B. n. log(n) C. n^2 D. 2^n E. n 19 Which of the following data structures is the fastest for retrieving data? A. Binary Index Tree B. Binary Tree C. Stack D. Queue E. Hash Table 20 Which of the following algorithm will be the first one to finish processing 1,000,000 element array (in the worst case scenario)? A. Quick Sort B. Linear Search C. Merge Sort D. Bubble Sort E. Heap Sort 21 Let A, B, C, and D be matrices whose dimensions are: A (2 x 4) B (4 x 3) C (3 x 1) D (1 x 5) What is the best way to multiply A x B x C x D (one with the smallest number of operations)? A. ( A x ( B x C ) ) x D B. ( ( A x B ) x C ) x D C. A x ( B x ( C x D ) ) D. A x ( ( B x C ) x D ) E. ( A x B ) x ( C x D ) BINUS UNIVERSITY Page 7

22 If you put 1, 3, 5, 9, 7 (in that order) into a stack, which number will be poped out last? A. 1 B. 3 C. 5 D. 9 E. 7 23 What is the result of the following expression? 6-5 - 4 * 3 / 2 + 1 A. -3 B. -2 C. 6 D. 1 E. -4 24 function f(n) if n <= 1 then return 1 if n mod 2 = 0 then return f(n/2) return f(3*n+1) How many times will the recursive function f(n) be called if it's invoked by f(3)? (including the initial call f(3)) A. 7 B. 8 C. 9 D. 10 E. 11 25 if (i = 3) OR (j = 4) then print "YES" print "NO" Are there any possibilities that the pseudocode will print both YES and NO in the same time? A. No, there are no possibilities. B. Yes, there are. Only one possibilities. C. Yes, there are. Many possibilities. BINUS UNIVERSITY Page 8

D. Yes, there are. Depends on compiler setting. E. Yes, there are. There are two possibilities. 26 It's BINUS Festival Day and you have a schedule of events: 9:00-9:45 Pop Band 9:30-10:00 Short Movie Theater 9:50-10:15 Chorus 10:00-10:30 Pongo Dance 10:10-10:25 Math Quiz 10:30-10:55 Wushu Demonstration 10:15-10:45 Poco Poco Dance 10:30-11:00 Programming Tutorial 10:45-11:30 Game Zone 10:55-11:25 Magician Show 11:00-11:15 Barongsai Dance Naturally, you want to attend as many events as you can. What is the largest set of nonoverlapping events? A. 2 B. 3 C. 4 D. 5 E. 6 27 function f(a,b,c) if (a = TRUE) AND (b = TRUE) then print '1' if (b = FALSE) then print '2' if (c = TRUE) then print '3' if (a = TRUE) and (b = FALSE) then print '4' print '5' What will be printed by f(false,true,true)? A. 1 B. 2 C. 3 D. 4 E. 5 28 What will be printed by the following pseudocode? S[1..5] = { 2, 8, 3, 6, 7 } BINUS UNIVERSITY Page 9

for x = 1 to 2 do for y = 1 to 4 do if S[x] < S[x+1] then z = S[x] S[x] = S[x+1] S[x+1] = z print S[2] A. 2 B. 8 C. 3 D. 6 E. 7 29 The following pseudocode will swap value x and y, except: A. x = x + y y = x - y x = x - y B. x = x XOR y y = y XOR x x = x XOR y C. x = x * y y = x / y x = x / y D. z = x x = y y = z E. x = x + y x = x - y y = y - x 30 What will be printed by the following pseudocode? S[1..7] = { 3, 1, 9, 7, 0, 4, 3 } x = 0 for i = 1 to 7 do for j = i + 1 to 7 do x = x + S[j] print x A. 87 B. 90 C. 94 D. 97 E. 101 BINUS UNIVERSITY Page 10

31 Let S = { 2, 3, 4, 5, 6, 10 }. How many non-empty set S' are there, such that S' is subset of S, and the product of all element is S' is a square number? A. 3 B. 4 C. 5 D. 6 E. 7 32 A B C D D ------- x D C B A Each letter represents a unique digit from 0 to 9. What is the correct value for C? A. 4 B. 5 C. 7 D. 8 E. 9 33 What is the last two digit of 7^1007? A. 07 B. 01 C. 49 D. 43 E. 35 34 How many trailing zero are there in 100! (100 x 99 x 98 x... 1)? A. 125 B. 24 C. 75 D. 47 E. 11 35 Find P, such that any amount of money greater than P can be formed by using 5-cent and 7-cent denomination! A. 24 B. 18 C. 23 D. 19 BINUS UNIVERSITY Page 11

E. 13 36 Supposed that there are four people (A, B, C and D) who play different kind of music instruments. If C is a pianist, then D would be a violinist. If D is a guitarist, then C would be a violinist. If A is a violinist, then B would be a guitarist. If B is a violinist, then A would not be a drummer. If A is a pianist, then B would not be a drummer. If A is a guitarist, then B would no be a drummer. If C is a drummer, then D would be a pianist If D is a pianist, then A would not be a violinist. The best combination for A, B, C and D consecutively is: A. violin, guitar, drum, piano B. guitar, violin, drum, piano C. drum, guitar, piano, violin D. piano, drum, violin, guitar E. violin, drum, guitar, piano 37 Let S = { A, B, C, D, E, F } be a set of unique integers. A is larger than F C is smaller than A D is larger than E B is smaller than F E is larger than A F is smaller than C What is the third largest element in S? A. A B. B C. C D. D E. E 38 A web development team consists of 5 members that will be selected from 4 candidate programmers (A, B, C, D) and 4 candidate graphic designers (P, Q, R, S). A refuses to work with D B refuses to work with P Q refuses to work with R D refuses to work with Q S refuses to work with A If B has been chosen, who will be the team graphic designers? A. S B. Q C. Q and S D. R and S BINUS UNIVERSITY Page 12

E. There's no team of 5 member can be formed 39 Let S = { 9, 6, 13, 8, 10, 15, 12, 21 } What is the length of the longest increasing subsequence of S? A. 4 B. 5 C. 6 D. 7 E. 8 40 A is taller than B D is taller than C C is about the same height with A E is taller than C These are correct statements, except: A. D is taller than B B. E is taller than B C. B is the shortest D. E is the tallest E. B is shorter than C 41 If we multiply all Prime Numbers below 1000, how many trailing zero are there? A. 13 B. 1 C. 5 D. 17 E. 2 42 What is the condition for the following equation so that it is always TRUE? 2^n > n^2 A. No condition. The expression is always TRUE. B. n < 3 C. n!= 3 D. n > 3 E. n > 4 43 You are given a bag full of coins of three different denominations { 5 cent, 6 cent, 7 cent }, and of infinite amount for each denomination. What is the minimum number of coins needed to get 29 cent amount? BINUS UNIVERSITY Page 13

A. 5 B. 7 C. 6 D. 4 E. There's no way to get 29 cent. 44 You are given a bag full of coins of three different denominations {4 cent, 6 cent, 13 cent}, and of infinite amount for each denomination. What is the minimum number of coins needed to get 28 cent amount? A. 4 B. 3 C. 6 D. 5 E. There's no way to get 28 cent. 45 If you have 10 people in a room and each person shakes hands with every other person exactly once, how many total handshakes happen? A. 45 B. 50 C. 55 D. 90 E. 100 46 Andy is not able to answer if the problem is too difficult If Andy is not able to answer, then he will get zero for the exam Andy get zero for the exam What is the correct conclusion? A. Andy is not able to answer B. If Andy is not able to answer, then the problem is too difficult C. If Andy doesn't get zero, then the problem is not too difficult D. Andy is able to answer E. The problem is not difficult 47 Among the following conditional statements, which one is a tautology? (notation: -> IF ^ AND v OR ~ NOT) A. (p ^ q) -> ~p B. p -> (p ^ q) C. ~(p -> q) -> ~q D. (p v q) -> (p ^ q) E. p ^ (p -> q) BINUS UNIVERSITY Page 14

48 input a input b input c x = a + b + c print x If x = 25, which statement will always give TRUE value? A. a >= 3 OR b >= 19 OR c >= 5 B. a >= 9 OR b >= 10 OR c >= 9 C. a + b >= 15 OR c >= 13 D. a + b >= 15 AND b + c >= 12 E. a >= 13 OR b >= 14 49 Let S be { 1, 2, 3, 4, 5, 6, 7, 8 }, and T be any subset of S with 5 elements. What is the correct statement? A. The sum of all elements in T will be larger than 15. B. At least one pair of element in T has the sum equal to 9. C. At least two pairs of elements in T has the sum equal to 7. D. The sum of the three smallest elements int T will be larger than 10. E. At least one pair of element in T has the difference equal to 5. 50 Every BINUSIAN has an internet account. Eko does not have an internet account. Albert has an internet account. What is the correct conclusion? A. Albert is not a BINUSIAN B. Albert is a BINUSIAN C. Eko is not a BINUSIAN D. Eko is a BINUSIAN A. No correct conclusion BINUS UNIVERSITY Page 15

Bina Nusantara Programming Contest for High School Student (BNPC-HS) 2007 Qualification Round (Programming Task) - 11 November 2007 Problem A Math for a Birthday Present Program File Input File Output File Time Limit math.cpp math.pas math.java math.in math.out 1 second Make sure your program read input from file math.in, and write output to file math.out! John have just given his daughter, Jane, her 2 nd birthday present, a box full of rubber balls with fancy cartoon character drawn on each ball. Each ball has a unique number from 0 to 9 labeled on it. Obviously, John gave these balls not just for another fancy birthday present, but he wanted his daughter to learn about numbers. First, John took N balls from the box and gave them to his daughter to hold. And then, he would ask them back by using one of these two queries: 1. "Give me the ball with the lowest number from what you have now" (let's call it the lowest query) 2. "Give me the ball with the highest number from what you have now" (let's call it the highest query) For each ball he received from his daughter, he would put it back into the box, and then he continued his queries until there was no more ball left on Jane. Surprisingly, Jane understood and chose the correct ball every time. Now, being happy with the potential of his daughter, John wants to teach his daughter to recognize pattern. First, John starts with the lowest query, and then he moves on with the highest query, and then the lowest query again, and so on, alternatively using the queries until all balls have been put back into the box. With this query pattern (using lowest and highest alternatively), write a program to simulate what Jane will give to her father. Assume that Jane always gives the correct ball to her father and note that John always starts with the lowest query. Input Specification Input consists of several test cases. Each test case begins with an integer N (1 <= N <= 10), the

number of ball that Jane have at the beginning. The next line contains N integers A 1..n, (0 <= A i <= 9), denoting the label for each ball. Input is terminated when N = 0 and should not be processed. Output Specification For each case, output the sequence of balls that Jane will give to her father following the query pattern. Each number in the sequence should be separated by a single space. Sample Input 5 2 9 1 3 7 8 2 1 3 5 9 7 0 6 0 Sample Output 1 9 2 7 3 0 9 1 7 2 6 3 5 BNPC-HS 2007 - Qualification Round

Bina Nusantara Programming Contest for High School Student (BNPC- HS) 2007 Qualification Round (Programming Task) - 11 November 2007 Problem B Square Lookup Program File Input File Output File Time Limit square.cpp square.pas square.java square.in square.out 1 second Make sure your program read input from file square.in, and write output to file square.out! Given a set S of N points in Cartesian coordinate, find the largest square that can be formed by choosing four distinct points from S. Input Specification The first line of input contains T, the number of test cases. Each case begins with an integer N (1 <= N <= 40). The next N following lines each consists of a pair of integers, the x and y coordinate of ith point of S in Cartesian coordinate respectively (-1000 <= x, y <= 1000). Output Specification For each case, output area of the largest square that can be formed by choosing four distinct points from S, rounded to two decimal points. Output "0.00" (without quote) if there are no squares can be formed. Sample Input 2 3 1 1 5 5 1 5 6 1 1 3 1 3 3 1 3 5 3

3 5 Sample Output 0.00 8.00 BNPC-HS 2007 - Qualification Round

Bina Nusantara Programming Contest for High School Student (BNPC-HS) 2007 Qualification Round (Programming Task) - 11 November 2007 Problem C Hall of Fame Program File Input File Output File Time Limit fame.cpp fame.pas fame.java fame.in fame.out 1 second Make sure your program read input from file fame.in, and write output to file fame.out! Every end of the month, BINUS holds an online contest on their website to prepare its students to be ready for ICPC (International Collegiate Programming Contest). The contest is similar to BNPC-HS, except that there is only one winner for every contest. To motivate the students, one of the coaches creates a leader board to show who won the most so far. The board will be updated at the end of each contest. Student with most wins will hold the top-ranked position. In a tie situation, the student with most wins before the last contest conducts should hold the top-ranked position. Students who hold the top-ranked position in the leader board for P consecutive month(s) will be listed in the Hall of Fame. Each student should be listed in the Hall of Fame at most once. Suppose that we know the result of every contest, write a program to find out how many students are there that would be listed in the Hall of Fame. Input Specification The first line of the input is an integer T, denoting the number of test cases will follow. Each test case begins with two integers, N (1 <= N <= 100) the number of contests that have been held from the beginning, and P (1 <= P <= 10) the number of consecutive month(s) for a student should hold top-ranked position to be listed in the Hall of Fame. The next N line, each contains a student name who won the i-th contest. Student s name will be at most 10 characters of lowercase alphabet(s). Output Specification

For each case, output in a single line the number of students who have been listed in the Hall of Fame. Sample Input 2 4 3 robert robert denny robert 6 1 rudi albert joni albert joni rudi Sample Output 1 2 BNPC-HS 2007 - Qualification Round