# | Problem | Pass Rate (passed user / total user) |
---|---|---|
10241 | moocFinal1_換銅板 |
|
10243 | moocFinal3_Max Pooling |
|
10244 | moocFinal4_高維度稀疏向量 |
|
10245 | Spiral Matrix |
|
Description
輸入不同面值的銅板,然後輸入一個金額,將全部可能的找零方式列出。
譬如有 3 種銅板面值分別是 1 元、5元、10元,假設要湊出 17 元,如果把找零方法表示成 "(1元個數,5元個數,10元個數)",總共會有下列幾種方法
(2,1,1)
(2,3,0)
(7,0,1)
(7,2,0)
(12,1,0)
(17,0,0)
排列順序的規則: 例如 (7,0,1) 先於 (12,1,0) 因為 7 比 12 小;而 (7,0,1) 和 (7,2,0) 的順序,因為第一個數目7 和 7 相等,這時候就要比第二個數目,而由於 0 小於 2 所以 (7,0,1) 先於 (7,2,0)。
Input
第一個數字 N 代表有幾種不同面值的銅板 (N <= 5)
接下來就是 N 個整數,表示 N 種對應的銅板面值
最後一個數字是要需要找零的金額
Output
列出每一種找零方法,用括號框住每個銅板的數量,數量之間用逗號隔開,每一種找零方法後面要換行。
不同的找零方法的排列順序要依照題目的規定。
Sample Input Download
Sample Output Download
Tags
Discuss
Description
輸入一個 N x N 矩陣,輸出一個新的 (N-2) x (N-2) 矩陣,新的矩陣的每個元素,對應到原來的矩陣 每一個 3 x 3 區塊的範圍內的最大值,例如輸入的矩陣是
10 20 30 90 30
50 60 30 20 50
80 50 70 60 20
90 40 30 20 80
20 30 40 50 90
輸出的矩陣
80 90 90
90 70 80
90 70 90
以輸出矩陣的左上角的 80 為例 因為它是原來輸入的矩陣的左上角 3 x 3 區域內的最大值:
10 20 30
50 60 30
80 50 70
又例如輸出的矩陣的中間的 70,是原本輸入矩陣的正中央 3x3 區塊內的最大值:
60 30 20
50 70 60
40 30 20
Input
第一行是一個整數 N,然後接下來 N 行,每行包含 N 個整數,總共 N*N 個整數。
N 的值最小是 3,最大不超過 10。
Output
N-2 行,每一行包含 N-2 個整數,兩個元素之間有一個空白隔開,每一行最後都要換行。
Sample Input Download
Sample Output Download
Tags
Discuss
Description
輸入兩個向量,計算向量內積值。
兩個向量的內積,是各項相乘然後加總。例如 [1,2,3] 和 [4,5,6] 內積是 1*4+2*5+3*6 = 32
我們考慮高維度的稀疏向量,也就是大多數的元素都是零,只有少數不為零。資料的表示方式如下
dim1: value1 dim2: value2 dim3:value3 … 0:0
最後以 0:0 結束。例如
向量 [0,5,0,0,9,0,0,33] 是一個 8 維向量,可表示成
2:5 5:9 8:33 0:0
值為0 的維度都可以忽略不需描述,只需記錄非零的維度。利用上述的表示法,讀取兩個向量,然後算出它們的內積。
Input
輸入兩行,分別對應到兩個整數向量。
向量維度最高不超過 2 的 31 次方。記憶體用量不超過 32 MB。每一行都是以 0:0 結束
Output
內積值
最後記得換行
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Given two positive integers M and N, construct an M-row, N-column matrix that comprises a sequence of numbers from 1 to M*N arranged in clockwise spiral order. For example, if M = 3 and N = 4, the matrix would be
1 2 3 4
10 11 12 5
9 8 7 6
If M = 4 and N = 4, the matrix would be
1 2 3 4
12 13 14 5
11 16 15 6
10 9 8 7
Now, given a query integer P (1 <= P <= M*N), you need to print the position of P in the spiral matrix. For example, if M = 4, N = 4, and P = 14, the position of the integer 14 is at the position of row = 2 and column = 3, so the output is
2 3
Input
The input contains three positive integers M N P, where M denotes the number of rows and N denotes the number of columns of the spiral matrix. Both M and N are not greater than 30. P is the query number.
Output
Print two integers that denote the row and column of the position of P. The two integers are separated by a blank. Print a newline at the end of the output.