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

2
0 46 3 4 -5 -22 -8 -32 24 27
2 31 -5 0 0 12 0 0 -49 12
 

Sample Output

46q+3r+4u-5v-22w-8x-32y+24z+27
2p+31q-5r+12w-49z+12
 
 
题目意思:这算是一个模拟多项式吧,将给的数据填充到表达式之中,得到一个多项式。
 
解题思路:这个题还是比较坑的,前前后后折腾了我好久,大概有下面几个坑点吧:
 
1.第一项和最后一项要单独拿出来看待,第一项是正数没有正号,负数带着负号;最后一项如果前面全是0,最后一项是负数带着负号,非负数则不需要符号。
2.其他每一项中系数为1和-1时,表达式应该是符号加未知数的组合。
 
 
 #include<stdio.h>
#include<string.h>
int main()
{
int t,i,j,flag;
int a[];
char s[]= {'p','q','r','u','v','w','x','y','z'};
scanf("%d",&t);
while(t--)
{
flag=;
for(i=; i<; i++)
{
scanf("%d",&a[i]);
}
for(i=; i<; i++)
{
if(a[i]!=)
{
if(flag==)///为第一个数
{
if(a[i]==-)
{
printf("-");
}
else if(a[i]!=)
{
printf("%d",a[i]);
}
}
else///不是一个数
{
if(a[i]>)
{
if(a[i]==)
{
printf("+");
}
else
{
printf("+%d",a[i]);
}
}
else
{
if(a[i]==-)
{
printf("-");
}
else
{
printf("%d",a[i]);
}
}
}
printf("%c",s[i]);
flag++;
}
else
{
continue;
}
}
if(flag>&&a[]>)
{
printf("+%d\n",a[]);
}
else if(flag>&&a[]==)
{
printf("\n");
}
else if(flag==&&a[]==)
{
printf("0\n");
}
else
{
printf("%d\n",a[]);
}
}
return ;
}
 

 
 
 
 

Linearization of the kernel functions in SVM(多项式模拟)的更多相关文章

  1. HDU 5095 Linearization of the kernel functions in SVM(模拟)

    主题链接:http://acm.hdu.edu.cn/showproblem.php? pid=5095 Problem Description SVM(Support Vector Machine) ...

  2. 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). ...

  3. 模拟 HDOJ 5095 Linearization of the kernel functions in SVM

    题目传送门 /* 题意:表达式转换 模拟:题目不难,也好理解题意,就是有坑!具体的看测试样例... */ #include <cstdio> #include <algorithm& ...

  4. HDU 5095--Linearization of the kernel functions in SVM【模拟】

    Linearization of the kernel functions in SVM Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: ...

  5. HDU 5095 Linearization of the kernel functions in SVM (坑水)

    比较坑的水题,首项前面的符号,-1,+1,只有数字项的时候要输出0. 感受一下这些数据 160 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 ...

  6. SVM Kernel Functions

    ==================================================================== This article came from here. Th ...

  7. Kernel Functions for Machine Learning Applications

    In recent years, Kernel methods have received major attention, particularly due to the increased pop ...

  8. Kernel Functions-Introduction to SVM Kernel & Examples - DataFlair

    Kernel Functions-Introduction to SVM Kernel & Examples - DataFlairhttps://data-flair.training/bl ...

  9. PAT l2-018 多项式A除以多项式B 【多项式+模拟】

    这仍然是一道关于A/B的题,只不过A和B都换成了多项式.你需要计算两个多项式相除的商Q和余R,其中R的阶数必须小于B的阶数. 输入格式: 输入分两行,每行给出一个非零多项式,先给出A,再给出B.每行的 ...

随机推荐

  1. 竞赛题解 - Palisection(CF-17E)

    Palisection(CF-17E) - 竞赛题解 Manacher学到一定程度,也需要练一下有趣的题了-- (这是多老的题了 \(QwQ\))[传送门] 『题意』 给出一个字符串,求总共有多少对不 ...

  2. js判断当前浏览器是否是源生app的webview

    有些时候,我们在开发过程中需要判断,当前页面被打开是否是处于源生的webview里面,或者NODEJS做服务器后端支持的时候,判断请求来源是否来至于源生webview里面被打开的页面请求GET/POS ...

  3. jQuery关于复选框的基本小功能

    这里是我初步学习jquery后中巨做的一个关于复选框的小功能: 点击右边选项如果勾上,对应的左边三个小项全部选中,反之全不选, 左边只要有一个没选中,右边大项就取消选中,反之左边全部选中的话,左边大项 ...

  4. Python入门 —— 03GUI界面编程

    GUI(Graphical User Interface) 即图形用户接口,又称图形用户接口. 是指采用图形方式显示的计算机操作用户界面.GUI 是屏幕产品的视觉体验和互动操作部分. "你的 ...

  5. 【Android】添加依赖包

    貌似好像不知一种方法,以后有时间再研究,下面是其中的一种方法

  6. django_orm 基本操作

    单表操作 增的操作: 一种方式:表名.objects.create(name='xxoo') 第二种方式:表名(name='xxoo') obj=表名(name='xxoo') obj.save() ...

  7. RMI入门HelloWorld

    java RMI(Remote Method Invocation)是一种基于java远程调用技术,是对RPC的java实现,可以在不同主机上进行通信与方法调用.PRC通信原理如图: 方法调用从客户对 ...

  8. Multiclonal Invasion in Breast Tumors Identified by Topographic Single Cell Sequencing

    Title:  Multiclonal Invasion in Breast Tumors Identified by Topographic Single Cell Sequencing 课题的目的 ...

  9. 优龙FS2410开发板学习过程遇到问题总结

    以下的问题及其解决办法是基于优龙FS2410开发板,不定期更新 ============================================================= 开发学习环境 ...

  10. 决策树算法之ID3与C4.5的理解与实现

    github:代码实现 本文算法均使用python3实现 1. 决策树   决策树(decision tree)是一种基本的分类与回归方法(本文主要是描述分类方法),是基于树结构进行决策的,可以将其认 ...