Educational Codeforces Round 25 A Binary Protocol 基础题
来源:互联网 发布:vc map数据如何拷贝 编辑:程序博客网 时间:2024/06/08 19:11
CF传送门
题意:
1. 给出一个只包含0和1的字符串,要求根据特殊编码要求输出编码后的数
2. 遇到1就用累加器把1累加为一个值输出
3. 遇到0就输出0的个数减1个0
题解:
没有题解,直接暴搜就好了
以下是我的AC代码:
#include <iostream>using namespace std;int main(){ int n,num=0; char str[91]; cin >> n; for(int i=0;i<n;i++) cin >> str[i]; for(int i=0;i<n;i++) { if(str[i]=='1') //遇到1就计算和直到遇到0才输出 num++; else //遇到0时会输出0的个数减1个0 { cout << num; num=0; //清零累加器 } } cout << num << endl; //最后一次累加的输出要另外处理 return 0;}
阅读全文
0 0
- Educational Codeforces Round 25 A Binary Protocol 基础题
- Educational Codeforces Round 25 A. Binary Protocol
- Educational Codeforces Round 25 A. Binary Protocol
- Educational Codeforces Round 25 B Five-In-a-Row 基础题
- Educational Codeforces Round 25A-G题解
- Educational Codeforces Round 5 A
- Educational Codeforces Round 20 A
- Educational Codeforces Round 21 A
- Educational Codeforces Round 23 A
- Educational Codeforces Round 25
- Educational Codeforces Round 25
- Educational Codeforces Round 25
- Educational Codeforces Round 25
- Educational Codeforces Round 25
- Educational Codeforces Round 20 Maximal Binary Matrix
- codeforce round A. Binary Protocol
- codeforces Educational Codeforces Round 21 A
- Educational Codeforces Round 25 B. Five-In-a-Row
- iOS编程学习十
- Python---非负整数转化成二进制字符串
- 读Zepto源码之Event模块
- 设计模式(15)-解释器模式
- AJAX基础
- Educational Codeforces Round 25 A Binary Protocol 基础题
- log4j配置
- sublime text3开发python并设置快捷键
- Educational Codeforces Round 25 B Five-In-a-Row 基础题
- offer面试题----1(字符串转换成整数)
- POJ 2054(Color a Tree-贪心)
- hdu 1317 spfa 算法 判断正环
- 30. Substring with Concatenation of All Words
- 对于程序员来说CPU是什么