Binary Protocol
这道题要唯一注意的一点就是数字0的表示——0个“1”来表达,所以字符串“100”所表示的数字就是100
附代码:
// Created by CAD on 2019/8/6.
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f
#define PII pair<int,int>
#define PIII pair<pair<int,int>,int>
#define mst(name, value) memset(name,value,sizeof(name))
#define FOPEN freopen("C:\\Users\\14016\\Desktop\\cad.txt","r",stdin)
#define test(n) cout<<n<<endl
using namespace std;
ll a=0;
int main()
{
int n;
string s;
cin>>n;
cin>>s;
int t=0;
for(int i=0;i<n;++i)
{
if(s[i]=='1') t++;
else if(s[i]=='0') a=a*10+t,t=0;
}
a=a*10+t;
cout<<a<<endl;
}
CAD加油!欢迎跟我一起讨论学习算法,QQ:1401650042