1045 - I2P CS 2016 Chen Midterm1 Practice Scoreboard

Time

2016/10/18 19:47:00 2016/10/27 13:30:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
10772 The number of occurrences
11149 Sequence Sorting
11158 Robot in maze
11160 GCD and LCM

10772 - The number of occurrences   

Description

Given a string A and n strings B1, B2, B3, …, Bn, count the number of occurrences of string A in each of B1, B2, B3, … , and print the maximum number of occurrences. All of the strings contain only digits.

 

For example, if A is “50” , n = 3, and the n strings are

“5005”

“055050”

“55000”

then your answer should be 2 because A appears in “5005”  one time,  in “055050” two times, and in “55000” one  time. So the maximum number of occurrences is 2.

 

Note that if A is “99” and B1 is “9999”, the number of occurrences of A in B1 is counted as 3.

You may assume string B1 is always longer than string A.

Input

The first line of the input is the string A (0<length of A<=4). The second line is n (1<n<10) .

For the next n lines, each line contains a string Bi (length of A < length of Bi <9) and a ‘\n’ at the end of the line.

Output

The maximum number of occurrences of A appears in B1, B2, …, Bn. Note that you DO NOT need to print ‘\n’ at the end of the output.

Sample Input  Download

Sample Output  Download

Tags

peko konpeko



Discuss




11149 - Sequence Sorting   

Description

Given an orderless integer sequence 

Please sort the sequence in ascending order 

Input

The first line contains a integer N, indicating the number of testcases.

You can use this format in your code:

int i , N;

scanf("%d",&N);

for(i=0;i<N;i++){

      // your code to deal with each testcase

}

The following lines are testcases.

Each testcase contains an integer sequence . the number in the integer sequence will be 0 ~ 9.

And the length of the integer sequence is smaller than 20.

There might be duplicated integers in the integer sequence

 

  

 

Output

The integer sequence sorted ascending.

Note that you have to add '\n' at the end of output

Sample Input  Download

Sample Output  Download

Tags




Discuss




11158 - Robot in maze   

Description

小智在火箭隊的地下基地裡遇到了迷宮.

迷宮裡每個 entry 上都有東南西北的方向, 表示要往哪個方向移動到下一個 entry.

那麼給定小智走進迷宮的起始位置, 小智走迷宮會有兩種狀況:

1. 跟著每個 entry 的方向走, 最後走出迷宮.

2. 跟著每個 entry 的方向走, 最後一直在裡面兜圈子.

 

假設小智站在迷宮北方選擇一個 column 走進迷宮,

請問小智最後有沒有走出迷宮?

如果有, 請印出小智走過 N 個 entry.

如果沒有, 請印出小智走過 A 個 entry 後踏入循環路線, 並印出循環路線的總長為 B 個 entry.

 

例如:

Grid1:  N為10

Grid2:  A為3, B為8

 

Hint:

1. 假設讀進來 map 大小為 (row, col), 可以開一個大小為 (row+2, col+2) 的 map, 外面一圈填上 -1, 裡面放讀到的 map. 
    這樣有助於判斷什麼時候走到地圖外 (走到 -1 就是走到原本的地圖外)

2. 可以印出地圖檢查自己每一步有沒有走對, 或檢查讀地圖有沒有讀對

3. 另外開一個 (row+2, col+2) 的 array 裡面都是 0, 當走到某個位置 (x, y) 就在 array 的 (x, y) 位置紀錄目前已經走過幾個 entry.
    這樣有助於判斷循環路線有多長, 因為只要遇到 array 裡不是 0 的地方就表示以下兩點皆成立:
        (1) 這個位置走過了
        (2) 這個位置是循環路線的起點, 把你現在走過的 entry 數減去這個位置的 entry 數能算出循環路線的長度

Input

Grid的row數  Grid的column數  小智從哪個column走進迷宮

迷宮

 

註1: 迷宮大小不超過10x10,  最小為2x2

註2: 每次只會有1筆測資

Output

N

A B

 

註: 最後不需加上換行

Sample Input  Download

Sample Output  Download

Tags




Discuss




11160 - GCD and LCM   

Description

Given three positive integers x, y, and z, compute their greatest common divisor (GCD) and least common multiple (LCM).

Input

The first line contains a positive integer N, which indicates the number of test cases in each input.

In the next N lines, each line contains three positive integer x, y, z.

 

Level 1: x, y, z < 10

Level 2: x, y, z < 10^2

Level 3: x, y, z < 10^3

Level 4: x, y, z < 10^4

Output

For each test case, output the GCD and LCM of x, y, and z in a line.

Note that you have to add '\n' at the end of output.

 

Sample Input  Download

Sample Output  Download

Tags




Discuss