• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            Problem G : Net Loss

            Rose N. Blatt is designing an embedded neural network to place inside a cell phone. When trained by the phone’s
            owner, the neural network will enable the user to dictate text messages in a hands-free way. The key idea in Rose’s
            design is the use of complicated polynomial response functions in each of the nodes of the network (rather than the
            more traditional thresholding functions used in many other neural nets). Figure 1 shows a portion of such a neural
            network (the polynomials are not accurately graphed).
            When Rose was ready to select her polynomials, she discovered a problem. Due to the limited amount of memory
            available, she did not have enough space to store all of the coefficients of the polynomials in her network. She has
            decided to use an approximation to each polynomial in the form of a continuous polygonal curve with two segments,
            y = aB1Bx + aB0B and y = bB1Bx + bB0B. The segments meet at a point whose x-coordinate, c, is between -1 and +1. Rose wants
            the approximation to be the best in the sense that the distance between p and the approximation function g is
            minimal. We define the distance between p and g as the integral of the square of their difference:
            For instance, if the polynomial is x^2-0.2, then the best polygonal approximation, with lines meeting at c = 0, is shown in Figure 2 (the dotted line shows the graph of the polygonal approximation).
            In the few bytes that are available for each node, Rose can store the values of aB1B, aB0B, bB1B, bB0B, and c as signed numbers.
            Fortunately Rose has a program that supplies her with a good guess for the value of c. Given this value, you are
            asked to help Rose find the optimal values for aB1B, aB0B, bB1B, and bB0B in the approximations to her polynomials.

            Input

            The input file contains multiple test cases. Each test case consists of three lines. The first line contains a positive
            integer n, 1 ≤ n ≤ 10, representing the degree of the polynomial p(x). This is followed by a line containing n +1
            numbers between -1 and 1 inclusive, which are the coefficients of p(x) from highest order term down to the constant
            term, expressed with at most three places after the decimal point. The last line for each test case contains the value
            for c, -1 < c < 1, expressed with at most three places after the decimal point.

            A line containing the integer zero follows the last test case.

            Output

            For each test case, print the case number (beginning with 1) and the four optimal values, displaying each with exactly
            three places after the decimal point. The first and second values are the parameters a1 and a0 of the line segment
            y = a1x + a0 defining g in the range -1 ≤ x ≤ c. The third and fourth values are the parameters b1 and b0 of the line
            segment y = b1 + b0 defining g in the range c ≤ x ≤ 1. The distance d(p,g) between p and g (as defined earlier)
            should be the minimum over all such choices for a1, a0, b1, and b0.

            Sample Input

            2
            1.0 0.0 -0.2
            0.0
            3
            1 0 -1 0
            0.707
            0

            Output for the Sample Input

            Case 1: -1.000 -0.367 1.000 -0.367
            Case 2: -0.499 -0.036 1.198 -1.236

            數學題,求函數g(x)里的常數項a0,a1,b0,b1,使得函數d(p,g)取得最值。
            在推導出極值條件后,需要實現多項式求值,多項式乘法和多項式定積分3個函數,便能解決問題。

            400027  2009-04-24 05:49:39 Accepted  0.002  Minimum  19193  C++  4124 - Net Loss
             1 #include <iostream>
             2 using namespace std;
             3 
             4 const int MAXPOW = 20;
             5 double a0,a1,b0,b1,A,B,C,D,E,F,G,H,I;
             6 struct poly{
             7     double c[MAXPOW];
             8     double value(double x) const{           //多項式求值
             9         double ans=0;
            10         for(int i=MAXPOW-1;i>=0;i--)
            11             ans=ans*x+c[i];
            12         return ans;
            13     }
            14     poly operator * (const poly &p) const{  //多項式乘法
            15         poly t;
            16         for(int i=0;i<MAXPOW;i++)
            17             for(int j=0;j<=i;j++)
            18                 t.c[i]+=p.c[i-j]*c[j];
            19         return t;
            20     }
            21     double integral(double a,double b) const{//定積分
            22         poly t;
            23         for(int i=1;i<MAXPOW;i++)
            24             t.c[i]=c[i-1]/i;
            25         return t.value(b)-t.value(a);
            26     }
            27     void clear(){
            28         memset(c,0,sizeof(c));
            29         }
            30     poly(){
            31         memset(c,0,sizeof(c));
            32     }
            33 }p,q;
            34 int main(){
            35     double c;
            36     int i,n,ca=1;
            37     while(scanf("%d",&n),n){
            38         p.clear();
            39         for(i=n;i>=0;i--) scanf("%lf",&p.c[i]);
            40         scanf("%lf",&c);
            41         q.c[1]=1,q.c[0]=-c;                 
            42         A=p.integral(-1,c) , B=q.integral(-1,c) , C=(p*q).integral(-1,c) , D=(q*q).integral(-1,c);
            43         E=p.integral(c,1) , F=q.integral(c,1) , G=(p*q).integral(c,1) , H=(q*q).integral(c,1);
            44         I=2*(A+E-B*C/D-F*G/H);
            45         a1=(C-I*B)/D , a0=I-c*a1 , b1=(G-I*F)/H , b0=I-c*b1;
            46         printf("Case %d: %.3lf %.3lf %.3lf %.3lf\n",ca++,a1,a0,b1,b0);
            47     }
            48     return 0;
            49 }

            posted on 2009-04-24 14:05 極限定律 閱讀(1189) 評論(0)  編輯 收藏 引用 所屬分類: ACM-ICPC World Final 2008題解

            <2025年5月>
            27282930123
            45678910
            11121314151617
            18192021222324
            25262728293031
            1234567

            導航

            統計

            常用鏈接

            留言簿(10)

            隨筆分類

            隨筆檔案

            友情鏈接

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            久久天天躁狠狠躁夜夜不卡| 久久久久久夜精品精品免费啦| 蜜臀av性久久久久蜜臀aⅴ麻豆| 欧美一级久久久久久久大片| 国产成人久久久精品二区三区 | 亚洲精品无码专区久久同性男| 91精品观看91久久久久久| 精品久久香蕉国产线看观看亚洲 | 久久久精品免费国产四虎| av无码久久久久久不卡网站| 色综合久久久久综合体桃花网| 无码专区久久综合久中文字幕| 久久亚洲私人国产精品vA| 久久天天躁狠狠躁夜夜96流白浆 | 婷婷久久香蕉五月综合加勒比| AV无码久久久久不卡蜜桃| 亚洲精品乱码久久久久久蜜桃图片 | 免费观看成人久久网免费观看| 久久不射电影网| 久久精品国产精品亚洲| 日本WV一本一道久久香蕉| 久久久久人妻精品一区| 久久婷婷久久一区二区三区| 久久精品成人免费国产片小草| 亚洲一区精品伊人久久伊人| 久久精品毛片免费观看| 国内精品久久久久久久亚洲| 久久精品国产男包| 久久久久久狠狠丁香| 国产99久久久国产精品小说| 久久亚洲精品人成综合网| 精品久久久久久国产三级| 久久久无码精品亚洲日韩蜜臀浪潮 | 亚洲精品美女久久久久99| 久久国产亚洲精品无码| 国产亚洲美女精品久久久| 99久久国产免费福利| 精品久久久久中文字| 久久久青草青青国产亚洲免观| 免费一级做a爰片久久毛片潮| 久久天天躁狠狠躁夜夜av浪潮|