Given that \(f(x)=x^3+kx^2-2x+1\) and that when \(f(x)\) is divided by \((x-k)\) the remainder is \(k\), find the possible values of \(k\).

When the polynomial \(p(x)\) is divided by \((x-1)\) the remainder is \(5\) and when \(p(x)\) is divided by \((x-2)\) the remainder is \(7\). Given that \(p(x)\) may be written in the form \[(x-1)(x-2)q(x)+Ax+B,\] where \(q(x)\) is a polynomial and \(A\) and \(B\) are numbers, find the remainder when \(p(x)\) is divided by \((x-1)(x-2)\).