主题链接: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. PCB板蛇形走线有什么作用

    PCB板蛇形走线有什么作用  PCB上的不论什么一条走线在通过高频信号的情况下都会对该信号造成时延时,蛇形走线的主要作用是补偿"同一组相关"信号线中延时较小的部分,这些部分一般是没 ...

  2. Jquery显示和隐藏元素或设为只读(含Ligerui的控件禁用,实例说明)

    一.隐藏和显示元素 $('#button_save_12').css('display', 'none'); // 隐藏按钮 $('#button_save_12').css('display', ' ...

  3. java线程例子登山

    Through its implementation, this project will familiarize you with the creation and execution of thr ...

  4. HDU 2504 又见GCD

    又见GCD Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Subm ...

  5. Hbase0.96源码之HMaster(二)Hmaster主要循环becomeActiveMaster

    1,Hmaster主循环主要这里主要有: 1,1 becomeActiveMaster(startupStatus); 1.2 finishInitialization 1.3 loop() beco ...

  6. 【Android进阶】Android面试题目整理与讲解(二)

    1. ArrayList,Vector, LinkedList 的存储性能和特性 ArrayList 和 Vector 都是使用数组方式存储数据,此数组元素数大于实际存储的数据以便增加和插入元素,它们 ...

  7. CentOS6.2安装memcache

    一,安装libevent # cd /tmp # wget http://www.monkey.org/~provos/libevent-1.3.tar.gz # tar -zxvf libevent ...

  8. 【原创】纯OO:从设计到编码写一个FlappyBird (一)

    说起来,自学计算机也有2年多的时间了,自己还没有从设计到编码,完完整整的设计一个基于面向对象的软件的经历..囧 于是,就有了这个系列.首先选用的语言是Java,没别的原因,HeadFirst设计模式是 ...

  9. 最常用的动态sql语句梳理Mybatis(转)

    公司项目中一直使用Mybatis作为持久层框架,自然,动态sql写得也比较多了,最常见的莫过于在查询语句中使用if标签来动态地改变过滤条件了.Mybatis的强大特性之一便是它的动态sql,免除了拼接 ...

  10. MY WAY程序(十三) 理念和技术

    背部,该项目团队去了一半多,我们出差.我将离开之前,闪亮强哥给了我学习技术的列表,以了解它:AngularJs,bootsrap,smartadmin,html5,css3.很多前景的技术.哎,学吧, ...