首页 > 其他 > 详细

hdu 5095 Linearization of the kernel functions in SVM 坑多的水题 细节

时间:2015-05-20 20:02:40      阅读:184      评论:0      收藏:0      [点我收藏+]

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5095

 

几个坑

系数为正负1是不输出系数(比赛时wa到死)

0时不输出但全零时要输出0

加号和减号的控制

 

#include <cstring>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <stack>
#include <vector>
#include <queue>
#include <map>
#include <set>

using namespace std;

const int maxn = 110;

int a[maxn];
const char ch[] = "pqruvwxyz";

int main()
{
    //freopen("in.txt", "r", stdin);

    int T;
    scanf("%d", &T);
    while(T--)
    {
        for(int i = 0; i < 10; i++)
            scanf("%d", &a[i]);

        bool flag = false;
        for(int i = 0; i < 9; i++)
        {
            if(a[i] > 0)
            {
                if(flag)
                    printf("+");

                if(a[i] == 1)
                    printf("%c", ch[i]);
                else
                    printf("%d%c", a[i], ch[i]);

                flag = true;
            }
            else if(a[i] < 0)
            {
                if(a[i] == -1)
                    printf("-%c", ch[i]);
                else
                    printf("%d%c", a[i], ch[i]);

                flag = true;
            }
        }

        if(!flag)
        {
            printf("%d", a[9]);
        }
        else
        {
            if(a[9] > 0)
                printf("+%d", a[9]);
            else if(a[9] < 0)
                printf("%d", a[9]);
        }
        printf("\n");


    }
    return 0;
}

 

hdu 5095 Linearization of the kernel functions in SVM 坑多的水题 细节

原文:http://www.cnblogs.com/dishu/p/4517784.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!