zoukankan      html  css  js  c++  java
  • HDU 5095 Linearization of the kernel functions in SVM (坑水)

    比较坑的水题,首项前面的符号,-1,+1,只有数字项的时候要输出0。

    感受一下这些数据

    16
    0 0 0 0 0 0 0 0 0 -1
    0 0 0 0 0 0 0 0 0 1
    0 0 0 0 0 0 0 0 0 0
    1 0 0 0 0 0 0 0 0 0
    -1 0 0 0 0 0 0 0 0 0
    -1 -1 -1 -41 -1 -1 -1 -1 -1 -1
    -1 5 -2 0 0 0 0 0 0 0
    1 1 1 1 1 1 1 1 1 1
    -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
    0 0 0 0 0 -1 -1 -1 -1 -1
    0 0 0 0 0 1 1 1 1 1
    1 1 1 1 1 0 0 0 0 0
    -1 -1 -1 -1 -1 0 0 0 0 0
    1 1 1 1 1 1 1 1 1 0
    0 46 3 4 -5 -22 -8 -32 24 27
    2 31 -5 0 0 12 0 0 -49 12

    #include<cstdio>
    #include<cstring>
    #include<cmath>
    char *bin = "pqruvwxyz";
    typedef int ll;
    
    ll a[10];
    int flag;
    void dfs(int d)
    {
        if(d == 9) {
            return;
        }
        if(a[d]){
            if(std::abs(a[d]) == 1){
                if(a[d]>0){
                    if(flag) printf("+");
                    printf("%c",bin[d]);
                }
                else printf("-%c",bin[d]);
            }
            else {
                if(a[d]>0){
                    if(flag) printf("+");
                    printf("%d%c",a[d],bin[d]);
    
                }else {
                    printf("%d%c",a[d],bin[d]);
                }
            }
            flag = 1;
    
        }
        dfs(d+1);
    }
    
    int main()
    {
        int n;
        scanf("%d",&n);
        while(n--){
           // memset(a,0,sizeof(a));
            for(int i = 0; i < 10; i++)
                scanf("%d",a+i);
            flag = 0;
            dfs(0);
            if(!flag){
                printf("%d",a[9]);
            }
            else {
                if(a[9]){
                    if(a[9]>0)
                        printf("+%d",a[9]);
                    else
                        printf("%d",a[9]);
                }
            }
            printf("
    ");
        }
        return 0;
    }
  • 相关阅读:
    【nodejs】vscode添加nodejs调试功能
    【nodejs】简单的httpserver
    windows下,强制关闭某端口号的进程
    git 客户端用户名密码配置
    【shell】变量替换
    aksk鉴权
    vue学习笔记-第一课
    好未来上海一面电面
    20190325面试题记录(中级java)
    IT帮-三月份-职业规划主题笔记
  • 原文地址:https://www.cnblogs.com/jerryRey/p/4654320.html
Copyright © 2011-2022 走看看