Skip to content

Instantly share code, notes, and snippets.

@butchi
Created October 14, 2014 16:01
Show Gist options
  • Save butchi/b55704bac456f2fd4570 to your computer and use it in GitHub Desktop.
Save butchi/b55704bac456f2fd4570 to your computer and use it in GitHub Desktop.
yukicoder No.40 多項式の割り算
(* http://yukicoder.me/problems/no/40 *)
cl[li_] :=
CoefficientList[PolynomialRemainder[FromDigits[Reverse[li], x], x^3 - x, x], x]
ans[{}] := {0}
ans[li_] := li
In[1]:= ans[f[{1, 1, 1, 0, 0, 1}]]
Out[1]= {1, 2, 1}
In[2]:= ans[cl[{0, -5 , 0, 4, 0, 1, -1, 0, 1}]]
Out[2]= {0}
In[3]:= ans[cl[{-5, 0, -1, 1, 1, 1}]]
Out[3]= {-5, 2}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment