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. 获取DOM

    <template> <div> <header-vue :msg="msg" ref="header">heheh< ...

  2. HTML+css3 图片放大效果

    <div class="enlarge"> <img src="xx" alt="图片"/> </div> ...

  3. ubuntu下安装应用(搜狗输入法)

  4. 【Hadoop故障处理】全分布下,DataNode进程正常启动,但是网页上不显示,并且DataNode节点为空

    [故障背景] DataNode进程正常启动,但是网页上不显示,并且DataNode节点为空. /etc/hosts   的ip和hostname配置正常,各个机器之间能够ping通. [日志错误信息] ...

  5. JS中数组方法的封装之slice

    slice方法的功能 // 1) : 数组的截取 // 2) :slice(m,n): 从数组索引m开始,截取到索引n,但是不包含n;[前包后不包] // slice(m) : 从索引m开始,截取到末 ...

  6. HyperLedger Fabric 1.4 Solo模式简介(10.1)

    Solo模式指单节点通信模式,该环境中只有一个排序(orderer)服务,从节点(peer)发送来的消息由一个orderer进行排序和产生区块:由于排序(orderer)服务只有一个orderer为所 ...

  7. LeetCode: 51. N-Queens(Medium)

    1. 原题链接 https://leetcode.com/problems/n-queens/description/ 2. 题目要求 游戏规则:当两个皇后位于同一条线上时(同一列.同一行.同一45度 ...

  8. andriod学习二 设置开发环境

    1.官方环境搭建步骤     http://developer.android.com/sdk/installing/index.html         包括:下载JDK6,Eclipse 3.6, ...

  9. hdu2112HDU Today(floyd+map数组对字符串的应用)

    HDU Today Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  10. thinkphp5保存远程图片到本地

    代码 protected function saveImg($imgUrl){ $ext=strrchr($imgUrl,'.'); if(!in_array($ext,['.jpg','.png', ...