首页 > 代码库 > Known Notation

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 long19 #define int64 __int6420 #define PI 3.141592721 /***************************************/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                 else70                 {71                     ce++;72                     numn+=1;73                     sum++;74                 }75             }76         }77         if (!ce&&s[len-1]!=*&&numX)78             sum++;79         printf("%d\n",sum);80     }81     return 0;82 }
View Code

 

Known Notation