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

题目链接: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;
}
时间: 2024-12-29 11:16:17

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

hdu 5095 Linearization of the kernel functions in SVM(模拟)

Linearization of the kernel functions in SVM Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 206    Accepted Submission(s): 109 Problem Description SVM(Support Vector Machine)is an important cl

HDU 5095 Linearization of the kernel functions in SVM(模拟)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5095 Problem 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

模拟 HDOJ 5095 Linearization of the kernel functions in SVM

题目传送门 1 /* 2 题意:表达式转换 3 模拟:题目不难,也好理解题意,就是有坑!具体的看测试样例... 4 */ 5 #include <cstdio> 6 #include <algorithm> 7 #include <iostream> 8 #include <cstring> 9 #include <cmath> 10 #include <string> 11 #include <vector> 12 #i

HDU5095——水过——Linearization of the kernel functions in SVM

Problem 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 t

hdoj-2095-Linearization of the kernel functions in SVM

Linearization of the kernel functions in SVM Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 2239 Accepted Submission(s): 599 Problem Description SVM(Support Vector Machine)is an important classif

hdu---5095---Linearization of the kernel functions in SVM

http://acm.hdu.edu.cn/showproblem.php?pid=5095 分析:当a[i]不为0的时候,就有输出; 输出内容:1.系数为正数且不是第一个位置输出一个'+'; 2.当系数为-1时且不是最后一个常数时输出一个'-'; 3.系数不是-1或1或者是最后那个常数时输出这个数: 4.最后一个位置没有字符要输出. Problem Description SVM(Support Vector Machine)is an important classification too

HDU 1040 As Easy As A+B (排序。。。水题)

题意:给定n个数,让你从小到大排序. 析:不说什么了. 代码如下: #include <cstdio> #include <iostream> #include <cstring> #include <algorithm> #include <cmath> using namespace std; const int maxn = 1000 + 5; int a[maxn]; int main(){ int T, n; cin >>

hdu 5095

Linearization of the kernel functions in SVM Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1001    Accepted Submission(s): 286 Problem Description SVM(Support Vector Machine)is an important cl

hdu 4274 Spy&amp;#39;s Work(水题)

Spy's Work Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1266    Accepted Submission(s): 388 Problem Description I'm a manager of a large trading company, called ACM, and responsible for the