# 它是多项式的因数吗？

11

(x-n)如果f(n)=0是一个函数，则多项式可以被因子整除f。您的工作：确定多项式函数f(x)是否可被整除(x-n)

# 例子

Input:(x^1-1),(x^1-1)
Output: True

Input: (x^1+2),(2x^2+4x^1+2)
Output: False

Input: (x^1+7),(x^2-49)
Output: True

### 规则

Alex A.

intboolstring 2015年

@intrepidcoder这不是重复项，因为问题不在于多项式。看看是否可以将多项式除以线性因子。
intboolstring 2015年

Digital Trauma 2015年

Answers:

5

# Pyth-39个字节

K_sPe:z"-|\+"3!v.ssXPtw,\^\x,"**""*K"\*

3

judge(mod(b,a)=0

1

# MATLAB，103 99 97 95 93字节

eval([regexprep(input(''),{'.+?1(.+)\),','(\d)x'},{'x=str2num(''\$1'');disp(~','\$1\*x'}) 41]);

t=sscanf(input(''),'(x^1%d),%s')';x=-t(1);disp(~eval(regexprep([t(2:end) ''],'(\d)x','\$1\*x')))

t=sscanf(input(''),'(x^1%d),%s')';

x=-t(1);

disp(

~eval(

regexprep(char([t(2:end) ''],'(\d)x','\$1\*x')
)
)

1

# VBScript，118116字节

a=inputbox(""):for i=0 to 9:a=replace(a,i&"x",i&"*x"):next:b=split(a,","):x=-eval(b(0)):msgbox not cbool(eval(b(1)))

1

# 公理77 180字节

f(a:UP(x,INT),b:UP(x,INT)):Boolean==(ground?(a)or ground?(b)=>false;p:=b;r:=a;if degree(a::POLY INT,x)>degree(b::POLY INT,x)then(p:=a;r:=b);(p rem r)\$UP(x,FRAC INT)~=0=>false;true)

v(a,b)==(ground?(a) or ground?(b) or (b rem a)\$UP(x,FRAC INT)~=0=>false;true)

(3) -> f(x^1-1,x^1-1)
(3)  true
Type: Boolean
(4) -> f(x^1+1,2*x^2+4*x^1+2)
(4)  true
Type: Boolean
(5) -> f(x^1+2,2*x^2+4*x^1+2)
(5)  false
Type: Boolean
(6) -> f(x^1+7,x^2-49)
(6)  true
Type: Boolean
(7) -> f(1, 1)
(7)  false
Type: Boolean
(8) -> f(1, x^2+1)
(8)  false
Type: Boolean
(9) -> f(x^8-1, x^2-1)
(9)  true
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.