zoukankan      html  css  js  c++  java
  • 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("
    ");
    
    
        }
        return 0;
    }
  • 相关阅读:
    Munge
    file upload custom form
    随笔摘要
    生成css 和 清缓存
    drupal commit 原则
    Git reset --hard
    www-data
    301/302的区别
    什么是request_uri
    in_array foreach array_search的性能比较
  • 原文地址:https://www.cnblogs.com/dishu/p/4517784.html
Copyright © 2011-2022 走看看