UVA-10719 Quotient polynomial

Source: Internet
Author: User

Click to open link

The other polynomial is determined by a polynomial, which is a law-finding problem.

Hypothesis: P (x) =a*x^4+b*x^3+c*x^2+d*x+f Q (x) =a1*x^3+b1*x^2+c1*x+d because p (x) = (x-1) * Q (x) so

A1=a b1-a1*k=b c1-k*b1=c d1-k*c1=d The corresponding coefficients can be obtained.

#include <cstdio> #include <cstring>int f1[10005],f2[10005];char s[100000];int main () {//freopen ("A.txt",    "R", stdin);    int k,i,n,cnt;        while (~SCANF ("%d", &k)) {GetChar ();        n=cnt=0;        int flag=0;        Gets (s);        int L=strlen (s);            for (i=0;i<l;i++) {if (s[i]== '-') flag=1;            else if (s[i]>= ' 0 ' &&s[i]<= ' 9 ') cnt=cnt*10+s[i]-' 0 ';                else {if (flag) {cnt=-cnt;flag=0;}                f1[n++]=cnt;                printf ("%d\n", CNT);            cnt=0;        }} if (flag) f1[n++]=-1*cnt;       else f1[n++]=cnt;        printf ("%d%d\n", cnt,n);        F2[0]=F1[0];        for (i=1;i<n;i++) {f2[i]=f1[i]+f2[i-1]*k;        } printf ("Q (x):");        for (i=0;i<n-1;i++) printf ("%d", f2[i]);        printf ("\ n");        printf ("R =%d\n", f2[n-1]);    printf ("\ n"); } return 0;}


UVA-10719 Quotient polynomial

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.