Binary Protocol

A. Binary Protocol

This question is to be the only note is that the number 0 is a - 0 "1" to express , so the string "100" number is represented by 100

With code:

// 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;
}


Guess you like

Origin www.cnblogs.com/CADCADCAD/p/11313345.html