zoukankan      html  css  js  c++  java
  • hdu 5095 Linearization of the kernel functions in SVM(模拟,分类清楚就行)

    题意:

    INPUT:

    The input of the first line is an integer T, which is the number of test data (T<120). Then T data follows. For each data, there are 10 integer numbers on one line, which are the coefficients and constant a, b, c, d, e, f, g, h, i, j of the function f(x,y,z) = ax^2 + by^2 + cy^2 + dxy + eyz + fzx + gx + hy + iz + j.

    OUTPUT:

    For each input function, print its correspondent linear function with 9 variables in conventional way on one line.

    样例:

    2
    0 46 3 4 -5 -22 -8 -32 24 27                         --->                        46q+3r+4u-5v-22w-8x-32y+24z+27

    2 31 -5 0 0 12 0 0 -49 12                             --->                        2p+31q-5r+12w-49z+12

    代码:

    char b[15]={'p','q','r','u','v','w','x','y','z'};
    int a[15];
    int T;
    
    int main(){
        //freopen("test.in","r",stdin);
        cin>>T;
        while(T--){
            rep(i,0,9) scanf("%d",&a[i]);
            int c=-1;
            rep(i,0,8) if(a[i]!=0) {c=i; break;}
            if(c==-1){
                printf("%d
    ",a[9]);
                continue;
            }
            if(abs(a[c])==1)
                if(a[c]>0) printf("%c",b[c]); else printf("-%c",b[c]);
            else
                printf("%d%c",a[c],b[c]); ++c;
            rep(i,c,8){
                if(a[i]==0) continue;
                if(abs(a[i])==1)
                    if(a[i]==1) printf("+%c",b[i]); else printf("-%c",b[i]);
                else
                    if(a[i]>0) printf("+%d%c",a[i],b[i]); else printf("%d%c",a[i],b[i]);
            }
            if(a[9]!=0){
                if(a[9]>0) printf("+%d
    ",a[9]); else printf("%d
    ",a[9]);
            }
            else
                printf("
    ");
        }
        //fclose(stdin);
    }
  • 相关阅读:
    算法提高 约数个数
    算法提高 第二大整数
    算法提高 逆序排列
    算法提高 c++_ch02_01
    算法提高 日期计算
    程序员教你设置密码
    fzu 2184 逆序数还原
    fzu 2146 Easy Game
    算法训练 区间k大数查询
    算法训练 最大最小公倍数
  • 原文地址:https://www.cnblogs.com/fish7/p/4085144.html
Copyright © 2011-2022 走看看