主题链接:http://acm.hdu.edu.cn/showproblem.php?

pid=5095

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 + cz^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 + cz^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 + cz^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
 
Source
 
Recommend

PS:

一道比較坑的模拟题。

注意1和-1 的情况。

代码例如以下:

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
int main()
{
int M;
int a[17];
char b[17] = {'#','p','q','r','u','v','w','x','y','z'};
scanf("%d",&M);
getchar();
while(M--)
{
for(int k = 1; k <= 10; k++)
{
scanf("%d",&a[k]);
}
int cont = 0;
int flag = 0;
for(int k = 1; k < 10; k++)
{
if(a[k]==0)
continue;
cont++;
if(cont == 1)
{
if(a[k] != 1 && a[k] != -1)
printf("%d%c",a[k],b[k]);
else if(a[k] == 1)
printf("%c",b[k]);
else if(a[k] == -1)
printf("-%c",b[k]);
flag = 1;
}
else
{
if(a[k] > 0)
printf("+");
if(a[k] != 1 && a[k] != -1)
printf("%d%c",a[k],b[k]);
else if(a[k] == 1)
printf("%c",b[k]);
else if(a[k] == -1)
printf("-%c",b[k]);
flag = 1;
}
}
if(a[10])
{
if(a[10] > 0 && flag)
printf("+");
printf("%d",a[10]);
flag = 1;
}
if(!flag)//没有答案
printf("0");
printf("\n");
}
return 0;
}
/*
99
0 0 0 0 0 0 0 0 0 -1
0 0 0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0
-1 0 0 0 0 0 0 0 0 0
-1 -1 -1 -41 -1 -1 -1 -1 -1 -1
-1 5 -2 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1 1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1
0 0 0 0 0 -1 -1 -1 -1 -1
0 0 0 0 0 1 1 1 1 1
1 1 1 1 1 0 0 0 0 0
-1 -1 -1 -1 -1 0 0 0 0 0
1 1 1 1 1 1 1 1 1 0
*/

版权声明:本文博客原创文章。博客,未经同意,不得转载。

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

  1. 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 ...

  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. Linearization of the kernel functions in SVM(多项式模拟)

    Description SVM(Support Vector Machine)is an important classification tool, which has a wide range o ...

  5. 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: ...

  6. Kernel Functions for Machine Learning Applications

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

  7. SVM Kernel Functions

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

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

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

  9. hdu 5095 多项式模拟+有坑

    http://acm.hdu.edu.cn/showproblem.php?pid=5095 就是把ax^2 + by^2 + cy^2 + dxy + eyz + fzx + gx + hy + i ...

随机推荐

  1. Eclipse常用热键

    ,Ctrl+D 删除选中的几行 ,Alt+上下箭头 移动选中的代码块 ,Alt+左右箭头 回退 前进 ,Alt+Shift+上下箭头 复制选中的代码块 ,sysout+Ctrl space 生成Sys ...

  2. JDBC与反射

    什么是JDBC Java定义了一套关于连接使用数据库的规范(接口)叫做JDBC,许多数据库厂商实现了这个规范,所以我们可以通过Java提供的接口编程,使得我们更换数据库的时候不用修改原来的代码,只需要 ...

  3. AS3.0下去除flash右键菜单

    这两天工作中遇到一个问题,就是网页中内嵌的flash小游戏的用户体验,当鼠标在flash上点击右键时,出现的右键菜单中会有播放,停止等选项,虽然不会造成什么漏洞,但是体验非常差.在寻找解决方案的时候, ...

  4. 【转载】SQL Server 2008 中新建用户登录并指定该用户的数据库

    提要:我在 SQL Server 中新建用户登录时,出现了三种错误,错误代码分别是 18456.15128.4064 -----------------------------------  正 文 ...

  5. 讨论asp.net通过机器cookie仿百度(google)实现搜索input搜索提示弹出框自己主动

    为实现自己主动弹出通过用户输入关键词相关的搜索结果,在这里,我举两个解决方案,对于两个不同的方案. 常用的方法是建立一个用户数据库中查找关系表.然后输入用户搜索框keyword异步调用数据表中的相关数 ...

  6. php获胜的算法的概率,它可用于刮,大转盘等彩票的算法

    php获胜的算法的概率,它可用于刮,大转盘等彩票的算法. easy,代码里有具体凝视说明.一看就懂 <?php /* * 经典的概率算法, * $proArr是一个预先设置的数组. * 假设数组 ...

  7. zoj3822 期望dp

    每天在一个n*m的棋盘上放棋子,问使得每一行,每一列都有棋子的期望天数 dp[n][m][k] 表示用k个棋子占据了n行,m列,距离目标状态还需要的期望天数 那么dp[n][m][k] = p1 * ...

  8. [Web Chart系列之五] 6. 实战draw2d之ConnectionRouter

    前言 ConnectionRouter 的作用是定义连线的展示样式. 是直线连接还是曲线连接(好像也是基于Bezier曲线) 位于包: draw2d.layout.connection 下. 常见的有 ...

  9. NYOJ 709(ZZULIOJ1481) 异 形 卵

    题目描写叙述 我们探索宇宙,是想了解浩瀚星空的奥妙,但我们却非常少意识到宇宙深处藏匿的危急,它们无时无刻不紧盯着我们的地球.假设外星人拜訪我们,结果可能与哥伦布当年踏足美洲大陆不会有什么两样,这是历史 ...

  10. JBOSS EAP6.2.0的下载安装、环境变量配置以及部署

    JBOSS EAP6.2.0的下载安装.环境变量配置以及部署 JBoss是纯Java的EJB(企业JavaBean)server. 第一步:下载安装 1.进入官网http://www.jboss.or ...