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;
    }
  • 相关阅读:
    noip2007 tg day1t1 统计数字
    洛谷1123 取数游戏
    洛谷1123 取数游戏
    素数筛
    bzoj 1297 [SCOI2009]迷路
    bzoj 2115 [Wc2011] Xor——路径和环的转化
    poj 2154 Color——带优化的置换
    bzoj 1407 [Noi2002]Savage
    poj 1286 Necklace of Beads
    bzoj 4031 [HEOI2015]小Z的房间
  • 原文地址:https://www.cnblogs.com/jerryRey/p/4654320.html
Copyright © 2011-2022 走看看