取ab=A
a+b=B
则原式=(A-1)^2+(B-2)(B-2A)
=A^2-2A+1+B^2-2AB-2B+4A
=A^2+2(1-B)A+B^2-2B+1
=A^2-2(B-1)+(B-1)^2
=(A-B+1)^2
=(ab-a-b+1)^2
=(a-1)^2(b-1)^2
取ab=A
a+b=B
则原式=(A-1)^2+(B-2)(B-2A)
=A^2-2A+1+B^2-2AB-2B+4A
=A^2+2(1-B)A+B^2-2B+1
=A^2-2(B-1)+(B-1)^2
=(A-B+1)^2
=(ab-a-b+1)^2
=(a-1)^2(b-1)^2