zoukankan      html  css  js  c++  java
  • Known Notation

    题目地址:Known Notation

    解题思路:

        o(︶︿︶)o 唉。

    代码:

     1 #include <algorithm>
     2 #include <iostream>
     3 #include <sstream>
     4 #include <cstdlib>
     5 #include <cstring>
     6 #include <cstdio>
     7 #include <string>
     8 #include <bitset>
     9 #include <vector>
    10 #include <queue>
    11 #include <stack>
    12 #include <cmath>
    13 #include <list>
    14 //#include <map>
    15 #include <set>
    16 using namespace std;
    17 /***************************************/
    18 #define ll long long
    19 #define int64 __int64
    20 #define PI 3.1415927
    21 /***************************************/
    22 const int INF = 0x7f7f7f7f;
    23 const double eps = 1e-8;
    24 const double PIE=acos(-1.0);
    25 const int d1x[]= {0,-1,0,1};
    26 const int d1y[]= {-1,0,1,0};
    27 const int d2x[]= {0,-1,0,1};
    28 const int d2y[]= {1,0,-1,0};
    29 const int fx[]= {-1,-1,-1,0,0,1,1,1};
    30 const int fy[]= {-1,0,1,-1,1,-1,0,1};
    31 const int dirx[]= {-1,1,-2,2,-2,2,-1,1};
    32 const int diry[]= {-2,-2,-1,-1,1,1,2,2};
    33 /*vector <int>map[N];map[a].push_back(b);int len=map[v].size();*/
    34 /***************************************/
    35 
    36 int main()
    37 {
    38     int cas;
    39     scanf("%d",&cas);
    40     while(cas--)
    41     {
    42         char s[1005];
    43         scanf("%s",s);
    44         int i,j;
    45         int len=strlen(s);
    46         int numN=0,numX=0;
    47         int sum=0;
    48         for(i=0;i<len;i++)
    49         {
    50             if (s[i]<='9'&&s[i]>='0')
    51                 numN++;
    52             if (s[i]=='*')
    53                 numX++;
    54         }
    55         sum=numX+1-numN;
    56         if (sum<0)
    57             sum=0;
    58         int numn=sum,ce=0;
    59         for(i=0;i<len;i++)
    60         {
    61             if (s[i]<='9'&&s[i]>='0')
    62                 numn++;
    63             if (s[i]=='*')
    64             {
    65                 if (numn>=2)
    66                 {
    67                     numn-=1;
    68                 }
    69                 else
    70                 {
    71                     ce++;
    72                     numn+=1;
    73                     sum++;
    74                 }
    75             }
    76         }
    77         if (!ce&&s[len-1]!='*'&&numX)
    78             sum++;
    79         printf("%d
    ",sum);
    80     }
    81     return 0;
    82 }
    View Code
  • 相关阅读:
    js/jquery/插件表单验证
    超级英雄在中国香港的平凡生活
    Nginx简单配置几个基于端口的虚拟主机
    Nginx配置简单基于域名的虚拟主机
    反驳关于“码农”的说法
    Nginx配置简单负载均衡
    Nginx Windows版安装及域名绑定
    转载:Java对Base64处理的细节
    转载:Base64编解码介绍
    多层If语句 和 表格驱动 的对比
  • 原文地址:https://www.cnblogs.com/ZhaoPengkinghold/p/4031978.html
Copyright © 2011-2022 走看看