Linearization of the kernel functions in SVM
来源:互联网 发布:数据库误删除没备份 编辑:程序博客网 时间:2024/05/17 22:47
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 Sample Output
Now your task is to write a program to change f into g.
20 46 3 4 -5 -22 -8 -32 24 272 31 -5 0 0 12 0 0 -49 12
46q+3r+4u-5v-22w-8x-32y+24z+272p+31q-5r+12w-49z+12
模拟:
用的笨方法,由于没考虑那么全,导致WA了好多遍,要注意1,-1,全为0的时候结果是0,为1或-1时,只写字母就行了,1,-1不用显现出来
#include<stdio.h>long long int a[100];int main(){ int t; scanf("%d",&t); while(t--) { int sum=0; int we; for(int i=1;i<=10;i++) { scanf("%lld",&a[i]); if(a[i]==0) { sum++; } } for(int i=1;i<=10;i++) { if(a[i]!=0) { we=i; break; } } if(sum==10) { printf("0\n"); } else { if(a[1]!=0) { if(a[1]==1) printf("p"); else if(a[1]==-1) printf("-p"); else printf("%dp",a[1]); } if(a[2]!=0) { if(a[2]>1&&2>we) printf("+%lldq",a[2]); else if(a[2]==1&&2>we) printf("+q"); else if(a[2]==1&&2<=we) printf("q"); else if(a[2]==-1) printf("-q"); else printf("%lldq",a[2]); } if(a[3]!=0) { if(a[3]>1&&3>we) printf("+%lldr",a[3]); else if(a[3]==1&&3>we) printf("+r"); else if(a[3]==1&&3<=we) printf("r"); else if(a[3]==-1) printf("-r"); else printf("%lldr",a[3]); } if(a[4]!=0) { if(a[4]>1&&4>we) printf("+%lldu",a[4]); else if(a[4]==1&&4>we) printf("+u"); else if(a[4]==1&&4<=we) printf("u"); else if(a[4]==-1) printf("-u"); else printf("%lldu",a[4]); } if(a[5]!=0) { if(a[5]>1&&5>we) printf("+%lldv",a[5]); else if(a[5]==1&&5>we) printf("+v"); else if(a[5]==1&&5<=we) printf("v"); else if(a[5]==-1) printf("-v"); else printf("%lldv",a[5]); } if(a[6]!=0) { if(a[6]>1&&6>we) printf("+%lldw",a[6]); else if(a[6]==1&&6>we) printf("+w"); else if(a[6]==1&&6<=we) printf("w"); else if(a[6]==-1) printf("-w"); else printf("%lldw",a[6]); } if(a[7]!=0) { if(a[7]>1&&7>we) printf("+%lldx",a[7]); else if(a[7]==1&&7>we) printf("+x"); else if(a[7]==1&&7<=we) printf("x"); else if(a[7]==-1) printf("-x"); else printf("%lldx",a[7]); } if(a[8]!=0) { if(a[8]>1&&8>we) printf("+%lldy",a[8]); else if(a[8]==1&&8>we) printf("+y"); else if(a[8]==1&&8<=we) printf("y"); else if(a[8]==-1) printf("-y"); else printf("%lldy",a[8]); } if(a[9]!=0) { if(a[9]>1&&9>we) printf("+%lldz",a[9]); else if(a[9]==1&&9>we) printf("+z"); else if(a[9]==1&&9<=we) printf("z"); else if(a[9]==-1) printf("-z"); else printf("%lldz",a[9]); } if(a[10]!=0) { if(a[10]>1&&10>we) printf("+%lld",a[10]); else if(a[10]==1&&10>we) printf("+1"); else if(a[10]==1&&10<=we) printf("1"); else if(a[10]==-1) printf("-1"); else printf("%lld",a[10]); } printf("\n"); } }}
0 0
- Linearization of the kernel functions in SVM
- Linearization of the kernel functions in SVM
- 【杂题】 HDOJ 5095 Linearization of the kernel functions in SVM
- 【瞎搞】 HDU 5095 Linearization of the kernel functions in SVM
- HDOJ 5095 Linearization of the kernel functions in SVM 坑题
- hdu 5095 Linearization of the kernel functions in SVM(模拟)
- hdu 5095 Linearization of the kernel functions in SVM(水题)
- HDU5095 Linearization of the kernel functions in SVM(模拟)
- HDU 5095 - Linearization of the kernel functions in SVM
- hdoj 5095 Linearization of the kernel functions in SVM 【模拟】
- HDU 5095--Linearization of the kernel functions in SVM【模拟】
- hdoj-2095-Linearization of the kernel functions in SVM
- HDU 5095 Linearization of the kernel functions in SVM【模拟】
- HDU 5095 Linearization of the kernel functions in SVM
- HDU 5095 Linearization of the kernel functions in SVM
- HDU 5095 Linearization of the kernel functions in SVM(模拟)
- HDU 5095Linearization of the kernel functions in SVM(水题)
- HDU 5095 Linearization of the kernel functions in SVM(模拟, 水题)
- php字符串转与整数比较,会把字符串转化为整数来比较
- Android Application的作用
- 【安卓学习之代码学习】 双卡知识学习
- PAT_乙级 1030 完美数列
- 视差效果实现
- Linearization of the kernel functions in SVM
- 第7章 Spring Boot的Web开发2
- mysql 有索引没走索引 更新锁全表
- Asp.net post 实例
- 绝了,我想起来了不启动流程取得第一任务的下一环节
- java 复习——数据类型
- 深入理解JavaScript系地址
- iOS--屏幕尺寸
- MySql-5.7.16 win64免安装版安装教程