欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

hdu 5095 Linearization of the kernel functions in SVM(模拟,分类清楚就行)

发布时间:2025/5/22 编程问答 45 豆豆
生活随笔 收集整理的这篇文章主要介绍了 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). 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.

 

样例:

2
0 46 3 4 -5 -22 -8 -32 24 27                         --->                        46q+3r+4u-5v-22w-8x-32y+24z+27

2 31 -5 0 0 12 0 0 -49 12                             --->                        2p+31q-5r+12w-49z+12

 

代码:

char b[15]={'p','q','r','u','v','w','x','y','z'}; int a[15]; int T;int main(){//freopen("test.in","r",stdin);cin>>T;while(T--){rep(i,0,9) scanf("%d",&a[i]);int c=-1;rep(i,0,8) if(a[i]!=0) {c=i; break;}if(c==-1){printf("%d\n",a[9]);continue;}if(abs(a[c])==1)if(a[c]>0) printf("%c",b[c]); else printf("-%c",b[c]);elseprintf("%d%c",a[c],b[c]); ++c;rep(i,c,8){if(a[i]==0) continue;if(abs(a[i])==1)if(a[i]==1) printf("+%c",b[i]); else printf("-%c",b[i]);elseif(a[i]>0) printf("+%d%c",a[i],b[i]); else printf("%d%c",a[i],b[i]);}if(a[9]!=0){if(a[9]>0) printf("+%d\n",a[9]); else printf("%d\n",a[9]);}elseprintf("\n");}//fclose(stdin); }

 

转载于:https://www.cnblogs.com/fish7/p/4085144.html

总结

以上是生活随笔为你收集整理的hdu 5095 Linearization of the kernel functions in SVM(模拟,分类清楚就行)的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。