113 - 高等程式設計 2012 - 第一次考試 Scoreboard

Time

2012/03/28 18:20:00 2012/03/28 22:30:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
1100 Easy Problem from Rujia Liu?
1104 DNA Sorting
1108 Product
1112 Simply Emirp

1100 - Easy Problem from Rujia Liu?   

Description

Category: Binary search

Though Rujia Liu usually sets hard problems for contests (for example, regional contests like Xi'an 2006, Beijing 2007 and Wuhan 2009, or UVa OJ contests like Rujia Liu's Presents 1 and 2), he occasionally sets easy problem (for example, 'the Coco-Cola Store' in UVa OJ), to encourage more people to solve his problems :D

Given an array, your task is to find the k-th occurrence (from left to right) of an integer v. To make the problem more difficult (and interesting!), you'll have to answer m such queries.

Input

There are several test cases. The first line of each test case contains two integers n, m (1 ≤ n, m ≤ 100,000), the number of elements in the array, and the number of queries. The next line contains n positive integers not larger than 1,000,000. Each of the following m lines contains two integer k and v (1 ≤ kn, 1 ≤ v ≤ 1,000,000). The input is terminated by end-of-file (EOF). The size of input file does not exceed 5MB.

Output

For each query, print the 1-based location of the occurrence. If there is no such element, output 0 instead.

Sample Input  Download

Sample Output  Download

Tags




Discuss




1104 - DNA Sorting   

Description

One measure of ``unsortedness'' in a sequence is the number of pairs of entries that are out of order with respect to each other. For instance, in the letter sequence ``DAABEC'', this measure is 5, since D is greater than four letters to its right and E is greater than one letter to its right. This measure is called the number of inversions in the sequence. The sequence ``AACEDGG'' has only one inversion (E and D)--it is nearly sorted--while the sequence ``ZWQM'' has 6 inversions (it is as unsorted as can be--exactly the reverse of sorted).

You are responsible for cataloguing a sequence of DNA strings (sequences containing only the four letters A, C, G, and T). However, you want to catalog them, not in alphabetical order, but rather in order of ``sortedness'', from ``most sorted'' to ``least sorted''. All the strings are of the same length.

Input

The first line of the input is an integer M, then a blank line followed by M datasets. There is a blank line between datasets.

The first line of each dataset contains two integers: a positive integer n (0 < n ≤ 50) giving the length of the strings; and a positive integer m (0 < m ≤ 100) giving the number of strings. These are followed by m lines, each containing a string of length n.

Output

For each dataset, output the list of input strings, arranged from ``most sorted'' to ``least sorted''. If two or more strings are equally sorted, list them in the same order they are in the input file.

Print a blank line between consecutive test cases.

Sample Input  Download

Sample Output  Download

Tags




Discuss




1108 - Product   

Description

The problem is to multiply two integers X, Y. (0 ≤ X, Y < 10250)

Input

The input will consist of a set of pairs of lines. Each line in pair contains one multiplier.

Output

For each input pair of lines, the output line should consist of one integer the product.

Sample Input  Download

Sample Output  Download

Tags




Discuss




1112 - Simply Emirp   

Description

An integer greater than 1 is called a prime number if its only positive divisors (factors) are 1 and itself. Prime numbers have been studied over the years by a lot of mathematicians. Applications of prime numbers arise in Cryptography and Coding Theory among others.

Have you tried reversing a prime? For most primes, you get a composite (43 becomes 34). An Emirp (Prime spelt backwards) is a Prime that gives you a different Prime when its digits are reversed. For example, 17 is Emirp because 17 as well as 71 are Prime. Notice that 131 is Prime but not Emirp because reverse of 131 is still 131. In this problem, you have to decide whether a number N is Non-prime or Prime or Emirp. Assume that 1 < N < 1000000.

Interestingly, Emirps are not new to NTU students. We have been boarding 199 and 179 buses for quite a long time!

Input

Input consists of several lines specifying values for N.

Output

For each N given in the input, output should contain one of the following:

 

  1. "N is not prime.", if N is not a Prime number.
  2. "N is prime.", if N is Prime and N is not Emirp.
  3. "N is emirp.", if N is Emirp.

 

Sample Input  Download

Sample Output  Download

Tags




Discuss