简单

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 + 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

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
真是个大坑,傻逼队友说一个一个判断,然后就,,,,就是用一个字符串搞定了
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<ctype.h>
#include<math.h>
#include<algorithm>


#define Max 0x3f3f3f3f
using namespace std;
char str[20]= {"pqruvwxyz"};


int main()
{
    int i, n, b[12];
    scanf("%d", &n);


    while(n--)
    {
        int f=0;


        for(i=0; i<10; i++)
            scanf("%d", &b[i]);


        for(i=0; i<10; i++)
        {
            if(b[i])
            {
                if(f && b[i]>0)
                    printf("+");


                if(b[i]==-1 && i!=9)
                    printf("-");


                if((b[i]!=1 && b[i]!=-1) || (i==9))
                    printf("%d", b[i]);


                if(i!=9)
                printf("%c", str[i]);
                f=1;
            }
        }
        printf("\n");
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
MATLAB是一种广泛应用于科学计算、工程设计、图像处理等领域的高级计算机语言和交互式环境。在MATLAB中,可以通过一些简单的命令实现图像的读取、处理和保存等操作。本篇介绍的是MATLAB中如何实现简易的黑白处理。 黑白处理是指将彩色图像转换为黑白图像,使图像中的所有像素只有黑色和白色两种颜色。在MATLAB中,可以通过以下几个步骤实现黑白处理: 1. 读取图像 使用MATLAB中的imread函数读取一张彩色图像,例如: ```matlab img = imread('test.jpg'); ``` 2. 灰度化处理 将彩色图像转换为灰度图像,使用MATLAB中的rgb2gray函数实现,例如: ```matlab gray_img = rgb2gray(img); ``` 3. 图像二值化 将灰度图像进行二值化处理,即将图像中的所有像素值转换为0或1,使用MATLAB中的im2bw函数实现,例如: ```matlab bw_img = im2bw(gray_img, 0.5); ``` 其中0.5是二值化的阈值,可以根据实际情况进行调整。 4. 图像反色处理 有时候我们需要将黑白图像的黑白颜色进行反转,即黑色变为白色,白色变为黑色。使用MATLAB中的imcomplement函数实现,例如: ```matlab bw_img = imcomplement(bw_img); ``` 5. 保存黑白图像 使用MATLAB中的imwrite函数保存处理后的黑白图像,例如: ```matlab imwrite(bw_img, 'test_bw.jpg'); ``` 通过以上几个步骤,就可以实现简易的黑白处理。在实际应用中,还可以对黑白图像进行其他处理,如图像增强、边缘检测等。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值