[Problem B4-易] Polynomials
成績: 0 / 倒扣: 0.8
Time Limit: 1 second
Problem Description
Problem Description
● EnglishTechnical Specification
Given a product (ax2 + bx + c)d, write a program to compute the coefficients of the resulting polynomial. For example, if (a, b, c, d) = (1, 2, 3, 2), we have (x2 + 2x + 3)2 = x4 + 4x3 + 10x2 + 12x + 9 and your program outputs the coefficients 1, 4, 10, 12 and 9. In this problem, a, b, c, d are all integers and d is at most three.
● Chinese
給定一個多項式乘積形式如下 : (ax2 + bx + c)d ,本題的工作是要算出多項式乘積展開後的各項係數。例如,給定 (a, b, c, d) = (1, 2, 3, 2) ,則 (x2 + 2x + 3)2 = x 4+ 4x3 + 10x2 + 12x + 9 ,你的程式需要輸出係數 1, 4, 10, 12 和 9 。 在這個問題裏 , 每個所給的數字皆為整數 ,而且 d 不會超過 3 。
● EnglishInput Format
● Chinese
- All the given numbers are integers.
- The range of each number is as follows:
- -100 ≤ a ≤ 100 and a ≠ 0
- -100 ≤ b ≤ 100
- -100 ≤ c ≤ 100
- 1 ≤ d ≤ 3
- 每個所給的數字皆為整數
- 每個數的限制範圍如下 :
- -100 ≤ a ≤ 100 且 a ≠ 0
- -100 ≤ b ≤ 100
- -100 ≤ c ≤ 100
- 1 ≤ d ≤ 3
● EnglishOutput Format
The first line is an integer which indicates the number of test cases. Each test case consists of four integers a, b, c, d, separated by spaces, in a line.
● Chinese
第一行是一個整數代表測試資料有幾筆。每一筆測試資料都用一行四個整數 a , b, c, d 來表示,整數之間以一個以上的空格分開。
● EnglishExample
For each test case, output the coefficients of (ax2 + bx + c)d in a line by the descending power of x , separated by spaces.
● Chinese
針對每一筆測試資料,依降冪順序輸出多項式的係數。兩筆資料之間以一個斷行隔開,兩係數之間以一個空格隔開。
Sample Input: | Sample Output: |
4 1 2 3 2 1 10 100 1 10 0 10 3 20 0 -1 2 | 1 4 10 12 9 1 10 100 1000 0 3000 0 3000 0 1000 400 0 -40 0 1 |
解法 : 想不到更簡單的方法~"~,因為題目表示d不超過3 ,所以我就用的暴力法....分開解
如果d==1則直接輸出,d==2則係數相乘一次,d==3則再乘一次
沒有留言:
張貼留言
注意:只有此網誌的成員可以留言。