• 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
  • 相关阅读:
    【转】C# 注册表简单操作
    [转]VC++之随父窗口变化调整控件大小/位置
    [转]vc 汉字汉语拼音首字母如何获取
    [转]浅析ActiveX控件的CAB压缩
    [转]VC6.0中使用MFC开发ActiveX及简单验证
    ElasticSearch增加索引字段
    单词缩写
    linux命令
    使用PR插件Twixtor Pro对视频补帧
    Linux创建脚本服务
  • 原文地址:https://www.cnblogs.com/ZhaoPengkinghold/p/4031978.html
Copyright © 2020-2023  润新知