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. 840. Magic Squares In Grid (5月27日)

    开头 这是每周比赛中的第一道题,博主试了好几次坑后才勉强做对了,第二道题写的差不多结果去试时结果比赛已经已经结束了(尴尬),所以今天只记录第一道题吧 题目原文 Magic Squares In Gri ...

  2. MySQL数据导入导出(一)

    今天遇到一个需求,要用自动任务将一张表的数据导入另一张表.具体场景及限制:将数据库A中表A的数据导入到数据库B的表B中(增量数据或全量数据两种方式):体系1和体系2只能分别访问数据库A和数据库B.附图 ...

  3. sublime text3配置python开发环境(windows版)

    安装阶段: sublime text3的安装: 下载网址:https://www.sublimetext.com/ 下载完成后 ,点击安装即可. 安装Package Control: 点击 Tools ...

  4. JavaSE环境下的shiro(源自腾讯课堂)

    Shiro作用: 认证(登录).授权(鉴权).加密(用户名/密码加密).会话管理(session).Web集成.缓存 apache官网可以下载 图一 图二 图三 图一 .二是配置文件内容,对于图三的: ...

  5. PHP运行原理之Opcodes

    在我之前的博客<Laravel5框架性能优化技巧>中提到开启OPcache可以提升php性能.那么为什么开启OPcache就可以提升php运行性能呢?这里就要提到php的运行原理了--Op ...

  6. 【C】关键字void的用法

    void有两种功能 [1]没有 [2]任意类型 void出现的位置不同会有不同的解释 [1]void func( void ) func左边的void,代表『没有返回值』 func右边的括弧里的voi ...

  7. python3 package management 包管理 实例

    包是一种组织管理代码的方式,包里面存放的是模块 用于将模块包含在一起的文件夹就是包 包内包含__init__.py标志性文件 定义一个学生类,一个sayhello函数,一个打印语句 # p01.py ...

  8. C语言中malloc函数的理解

    在C语言中malloc函数主要是用在堆内存的申请上,使用malloc函数时,函数会返回一个void *类型的值,这个值就是你申请的堆内存的首地址:为什么返回的地址是一个void *类型的地址呢?首先我 ...

  9. 我和Python的Py交易》》》》》》 命名空间的小弟作用域

    命名空间的小弟作用域 在这要明确一个观点,在Python中万物皆对象,而变量指向的就是对象. 变量可以是 类名,函数名,储存数据的变量…… 对象可以是  类 ,被封装的一段代码(函数),数据…… 命名 ...

  10. sas简单使用

    1 数据存取: 逻辑库: libname  自己起的名字 ‘文件所在的路径’,若无这步数据则存在默认的work中. 另一个方法在sas里自己建立一个逻辑库,但是关闭后就消失了. 新建数据:data  ...