HDU 5095 Linearization of the kernel functions in SVM
#include<iostream>
#include<cstdio>
using namespace std;
char ch[]="pqruvwxyzj";
int main(){
int T;
scanf("%d",&T);
while(T--){
int flag=0,a;
for(int i=0;i<10;i++){
scanf("%d",&a);
if(i<9){
if(a==0) continue;
if(flag){
if(a==1) printf("+%c",ch[i]);
else if(a==-1) printf("-%c",ch[i]);
else if(a>0) printf("+%d%c",a,ch[i]);
else printf("%d%c",a,ch[i]);
}
else{
if(a==1) printf("%c",ch[i]);
else if(a==-1) printf("-%c",ch[i]);
else printf("%d%c",a,ch[i]);
}
flag=1;
}
else{
if(a==0) continue;
if(flag){
if(a>0) printf("+%d",a);
else printf("%d",a);
}
else{
printf("%d",a);
}
flag=1;
}
}
if(flag==0) printf("0");
printf("\n");
}
return 0;
}