HDU---5095---linearization of the kernel functions in SVM

Source: Internet
Author: User
Tags integer numbers svm

http://acm.hdu.edu.cn/showproblem.php?pid=5095

Analysis: When A[i] is not 0, there is output;

Output content: 1. The coefficient is positive and is not the first position to output a ' + ';

2. Output a '-' when the coefficient is-1 and not the last constant;

3. Output this number when the coefficient is not 1 or 1 or the last constant;

4. Last position no characters to output.

Problem DESCRIPTIONSVM (support Vector machine) are an important classification tool, which have a wide range of applications In cluster analysis, community division and so on. The SVM the kernel functions used in SVM has 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) are realized by setting the Corre Spondence 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 are a line AR function with 9 variables.
Now your task was to write a program to change F into G.

Inputthe input of the first line is a integer T, which is the number of test data (t<120). Then T data follows. For each data, there is the integer numbers on one line, which is 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.

Outputfor each input function, the print its correspondent linear function with 9 variables in conventional-on-one line.

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

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

SOURCE2014 Shanghai National Invitational Competition--re-title (thanks to Shanghai University for its topics)

Recommendhujie | We have carefully selected several similar problems for you:5808 5807 5806 5805 5804
#include <cstdio>#include<cstring>#include<iostream>#include<cmath>#include<vector>#include<algorithm>using namespacestd;#definePI 3.1415926Const intmaxn=1000007;Const intinf=0x3f3f3f3f;Charstr[Ten]={"pqruvwxyz"};inta[Ten];intMain () {intT; scanf ("%d", &T);  while(t--)    {         for(intI=0; i<Ten; i++) scanf ("%d", &A[i]); intf=0;  for(intI=0; i<Ten; i++)        {            if(A[i])///when A[i] is not 0, there is output;            {                if(F && a[i]>0) printf ("+");///the coefficients are positive and not the first position outputs a ' + ';                if(a[i]==-1&& i!=9) printf ("-");///outputs a '-' when the coefficient is 1 and not the last constant;                if((a[i]!=-1&&a[i]!=1) || (i==9)) printf ("%d", A[i]);///the number is output when the coefficient is not 1 or 1 or the last constant .                if(i!=9) printf ("%c", Str[i]);///last position no characters to outputF=1;///Mark Judgment}} printf ("\ n"); }    return 0;}

HDU---5095---linearization of the kernel functions in SVM

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.