【瞎搞】 HDU 5095 Linearization of the kernel functions in SVM

坑点:

系数为1的时候

全为0 的时候

开头 的+号

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <string>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <cmath>
using namespace std;
#include <queue>
#include <stack>
#include <vector>
#include <deque>
#define cler(arr, val)    memset(arr, val, sizeof(arr))
typedef long long  LL;
const int MAXN = 100200;
const int MAXM = 6000010;
const int INF = 0x3f3f3f3f;
const int mod = 1000000007;
int a[111];
char s[13]={'p','q','r','u','v','w','x','y','z',0};
int main()
{

#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#endif
    int t;
    cin>>t;
    while(t--)
    {
        for(int i=0;i<10;i++)
            cin>>a[i];
        int j=0,p;
        for(;j<10;j++)
        {
            if(a[j]!=0)
            {
                p=j;
                break;
            }
        }
      //  if(j==10){ printf("0\n");continue;}
        for(;j<10;j++)
        {
            if(a[j]!=0)
            {
                if(p!=j&&a[j]>0)printf("+");
                if((a[j]!=1&&a[j]!=-1)||j==9)
                {
                    if(j==9)
                        printf("%d",a[j]);
                    else
                    printf("%d%c",a[j],s[j]);
                }
                else
                {
                    if(a[j]==-1) printf("-");
                    if(j!=9)
                        printf("%c",s[j]);
                }
            }
        }
        puts("");
    }
    return 0;
}


posted @ 2014-11-02 18:24  kewowlo  阅读(153)  评论(0编辑  收藏  举报