hdu 5095模拟

来源:互联网 发布:国内皮鞋品牌 知乎 编辑:程序博客网 时间:2024/06/01 12:40

Linearization of the kernel functions in SVM

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 134 Accepted Submission(s): 83


Problem Description
SVM(Support Vector Machine)is an important classification tool, which has a wide range of applications in cluster analysis, community division and so on. SVM The kernel functions used in SVM have many forms. Here we only discuss the function of the form f(x,y,z) = ax^2 + by^2 + cy^2 + dxy + eyz + fzx + gx + hy + iz + j. By introducing new variables p, q, r, u, v, w, the linearization of the function f(x,y,z) is realized by setting the correspondence x^2<-> p, y^2 <-> q, z^2 <-> r, xy<-> u, yz <-> v, zx <-> w and the function f(x,y,z) = ax^2 + by^2 + cy^2 + dxy + eyz + fzx + gx + hy + iz + j can be written as g(p,q,r,u,v,w,x,y,z) = ap + bq + cr + du + ev + fw + gx + hy + iz + j, which is a linear function with 9 variables.

Now your task is to write a program to change f into g.

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.

Sample Input
20 46 3 4 -5 -22 -8 -32 24 272 31 -5 0 0 12 0 0 -49 12

Sample Output
46q+3r+4u-5v-22w-8x-32y+24z+272p+31q-5r+12w-49z+12

Source
2014上海全国邀请赛——题目重现(感谢上海大学提供题目)  
#include<stdio.h>char str[12]=" pqruvwxyz";int main(){    int t,a[12],i,flag,j;    scanf("%d",&t);    while(t--)    {        flag=0;        for(i=1;i<=10;i++)            scanf("%d",&a[i]);        for(i=1;i<=10;i++)            if(a[i]!=0)              break;        if(i==11)        {            printf("0\n");            continue;        }        for(j=i;j<=10;j++)        {            if(a[j]==0) continue;            else if(a[j]==1&&j==10&&j!=i)            {                printf("+1");            }            else if(a[j]==-1&&j==10)            {                printf("-1");            }            else if(a[j]==1&&j==10&&j==i)            {                printf("1");            }            else if(a[j]==-1)                printf("-");            else if(a[j]==1&&j!=i)                printf("+");            else if(a[j]>0)            {                if(j!=i)                  printf("+%d",a[j]);                else if(j==i)                {                  if(a[j]!=1)                     printf("%d",a[j]);                }            }            else if(a[j]<0)            {                printf("%d",a[j]);            }            if(j!=10)            {                printf("%c",str[j]);            }        }        printf("\n");    }    return 0;}/*0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0 -10 0 0 0 0 0 0 0 0 120 0 0 0 0 0 0 0 0 -121 1 1 1 1 1 1 1 1 11 1 1 1 1 1 1 1 1 01 0 1 0 1 0 1 0 1 00 1 0 1 0 1 0 1 0 10 1 2 3 0 4 5 6 0 71 2 3 4 5 6 7 8 9 10*/


0 0
原创粉丝点击