[Algorithm] Polynomial problems

排序:nlogn

二分查找:logn <-- 利用单调性,查n次,每次logn

Multiply the following pairs of polynomials using at most the prescribed number
of multiplications of large numbers (large numbers are those which depend on the
coefficients and thus can be arbitrarily large).

Hint:

Let‘s set x^2 = y. 最高次幂变为3。再执行点乘后,P(x)*Q(x)有(3+3+1)个系数。

Sol 1: n^2 denotes 组合方式,这是等式一侧;等式另一侧是查找logn。

Sol 2:

(1) 求任意两个变量的和,构成一个n^2长的数组。--O(n^2),每个数组下记录了由哪两个值相加。

(2) 对n^2长的数组排序。 -- n^2*log(n^2)

(3) 搜索某个值,也就是等式右边的值。 -- n^2

If m + n = a + b, 等价于在n^2长的数组上做上述类似的操作。

Therefore, 只要是两个变量的运算,就可以匹配这个O(n^2)的部分。思维简单,费空间而已。

When f(x) = x*sqrt(x+1)

这里的常数1是个tricky.

去掉它,x^(3/2)

变为x,sqrt(2)*[x^(3/2)]

可见,f(x)~O(x^(3/2))

时间: 2024-10-05 23:00:13

[Algorithm] Polynomial problems的相关文章

Draft-TCAD

IEEEtran.cls 1 %% 2 %% IEEEtran.cls 2007/03/05 version V1.7a 3 %% 4 %% 5 %% This is the official IEEE LaTeX class for authors of the Institute of 6 %% Electrical and Electronics Engineers (IEEE) Transactions journals and 7 %% conferences. 8 %% 9 %% S

Draft-JSS模板

IEEEtran.cls 1 %% 2 %% IEEEtran.cls 2007/03/05 version V1.7a 3 %% 4 %% 5 %% This is the official IEEE LaTeX class for authors of the Institute of 6 %% Electrical and Electronics Engineers (IEEE) Transactions journals and 7 %% conferences. 8 %% 9 %% S

基于数值分析思想对多项式求值的原理和应用进行探究

摘要:多项式是由多个单项(符号项如:5x或者常数项4)通过四则运算组合起来的式子,如P(x)=2x^4+3x^3-3x^2+5x-1 一般的求解会将特定的x代入到上式中,一个一个的计算,共需要花费10次的乘法和4次加法运算,但是我们可以通过霍纳方法对多项式进行组合计算,在需要每秒对多个不同输入的x多次计算多项式对应的值时,该方法可以极大的提高计算效率. 原理:采用霍纳方法对上式进行分解步骤如下: P(x) = -1+x(5-3x+3x^2+2x^3) = -1+x(5+x(-3+3x+2x^2)

polynomial time

https://en.wikipedia.org/wiki/Time_complexity#Polynomial_time An algorithm is said to be of polynomial time if its running time is upper bounded by a polynomial expression in the size of the input for the algorithm, i.e., T(n) = O(nk) for some consta

Algorithm - Introduction

Goal: Use Computer to solve problems step by step!!! What is Computer Science? Computer Science is the study of problems, problem-solving, and the solutions that come out of the problem-solving process. What is Programming? Programming is the process

poj 2151 Check the difficulty of problems

dp[i][j][s]表示第i个人,在前j个问题解决了s个问题 dp[i][j][s]=dp[i][j-1][s-1]*p[i][j]+dp[i][j-1][s]*(1-p[i][j]); 1 #include<iostream> 2 #include<string> 3 #include<cstdio> 4 #include<vector> 5 #include<queue> 6 #include<stack> 7 #include

POJ 2151 Check the difficulty of problems (概率dp)

题意:给出m.t.n,接着给出t行m列,表示第i个队伍解决第j题的概率. 现在让你求:每个队伍都至少解出1题,且解出题目最多的队伍至少要解出n道题的概率是多少? 思路:求补集. 即所有队伍都解出题目的概率,减去所有队伍解出的题数在1~n-1之间的概率 这里关键是如何求出某个队伍解出的题数在1~n-1之间的概率,采用dp的方法: 用p(i,j)表示前i道题能解出j道的概率,有p(i,j)=p(i-1,j)*(1-p(i))+p(i-1,j-1)*p(i)p(i)表示解出第i题的概率. #inclu

POJ 2151 Check the difficulty of problems(概率dp)

Language: Default Check the difficulty of problems Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 5419   Accepted: 2384 Description Organizing a programming contest is not an easy job. To avoid making the problems too difficult, the org

[Algorithm] A* Search Algorithm Basic

A* is a best-first search, meaning that it solves problems by searching amoung all possible paths to the solution(goal) for the one that incurs the smallest cost(least distance, shortest time, etc.), and among these paths it first considers the one t