主题链接: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. iOS_16_开关控制器_modal_代码方法

    最后效果图: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcHJlX2VtaW5lbnQ=/font/5a6L5L2T/fontsize/400/fill ...

  2. SWT的对话框们

    对话框,都继承自org.eclipse.swt.widgets.Dialog,有Modal的和Modeless的区分,一般的对话框处理程序如下: <DialogType> dlg = ne ...

  3. wp天气预报

    ak url  http://developer.baidu.com/map/index.php?title=car 后台cs using System; using System.Collectio ...

  4. apache +php +php curl 模块设置

    2.2 linux 下面 2.2.1 web服务器安装 1目前采用的web服务器是apache2,在ubuntu 下安装 apt-getupdate apt-get installapache2 测试 ...

  5. mysql 利用触发器(Trigger)让代码更简单

    一,什么触发器 1,个人理解 触发器,从字面来理解,一触即发的一个器,简称触发器(哈哈,个人理解),举个例子吧,好比天黑了,你开灯了,你看到东西了.你放炮仗,点燃了,一会就炸了. 2,官方定义 触发器 ...

  6. POJ 3181 Dollar Dayz 简单DP

    这DP虽然简单 但是思考一下还是挺好的 题意是 1,2,3,4....k 用加法凑成N 每个数可取不限个数 令dp[i][j] 表示前i种数凑成j的方案数 然后dp[i][j] = dp[i - 1] ...

  7. android细节之禁用activity的系统的默认切换效果

    网上有非常多方法来禁用系统的默认效果,这里贴上来我觉得最简单的方法. overridePendingTransition(Animation.INFINITE, Animation.INFINITE) ...

  8. Android 关于资源适配

    一. 关于图片资源 图片宽高 不要固定大小,在小屏幕和大屏幕,不同分频率上 ,採用不同的图片,这个要美工切图的. 不同的分辨率,界面的长宽比不一致,须要不同规格的图片 在drawable-hdpi,d ...

  9. leetcode先刷_Binary Tree Level Order Traversal II

    非常easy标题,在后面,我不认为它不是那么简单的回答更多的.我们将编写,没有人啊. 预购在基层上,加上节省每一层,加上从下往上的输出,是一家vector而一个stack那么问题,没有他,但另一方面- ...

  10. 上市ASCII 表省内发现!

    表格来自,这里 扩展码表: