标签:des style io color ar os java for sp
2 0 46 3 4 -5 -22 -8 -32 24 27 2 31 -5 0 0 12 0 0 -49 12
46q+3r+4u-5v-22w-8x-32y+24z+27 2p+31q-5r+12w-49z+12
有 -1 和 1 的情况 , 考虑清楚就ok了 。
#include <iostream>
#include <cstdio>
using namespace std;
const int maxn = 15 ;
const char ch[maxn] = {'p','q','r','u','v','w','x','y','z','j'};
int a[maxn];
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
for(int i=0; i<10; i++) scanf("%d",&a[i]);
a[10]=99;
int cnt=0;
while(a[cnt]==0) cnt++;
if(cnt==10)
{
cout<<"0"<<endl;
continue;
}
if(cnt==9) cout<<a[cnt];
else
{
if(a[cnt]==1) cout<<ch[cnt];
else if(a[cnt]==-1) cout<<"-"<<ch[cnt];
else cout<<a[cnt]<<ch[cnt];
}
for(int i=cnt+1; i<10; i++)
{
if(a[i]==0) continue;
if(a[i]>0) cout<<"+";
if(i==9) cout<<a[i];
else
{
if(a[i]==1) cout<<ch[i];
else if(a[i]==-1) cout<<"-"<<ch[i];
else cout<<a[i]<<ch[i];
}
}
cout<<endl;
}
return 0;
}
hdu 5095 Linearization of the kernel functions in SVM(模拟)
标签:des style io color ar os java for sp
原文地址:http://blog.csdn.net/u012596172/article/details/40824047