Code Parsing CodeForces
来源:互联网 发布:镧系元素物理性质知乎 编辑:程序博客网 时间:2024/05/23 02:01
http://codeforces.com/problemset/problem/255/B
Note
In the first test the algorithm will end after the first step of the algorithm, as it is impossible to apply any operation. Thus, the string won’t change.
In the second test the transformation will be like this:
string “yxyxy” transforms into string “xyyxy”;
string “xyyxy” transforms into string “xyxyy”;
string “xyxyy” transforms into string “xxyyy”;
string “xxyyy” transforms into string “xyy”;
string “xyy” transforms into string “y”.
As a result, we’ve got string “y”.
In the third test case only one transformation will take place: string “xxxxxy” transforms into string “xxxx”. Thus, the answer will be string “xxxx”.
#include<stdio.h>#include<stdlib.h>#include<string.h>int main(){ int i,j,n,flag,flagm,k; char ch[1000001]; while (gets(ch)) { flag = 0; flagm = 0; n = strlen(ch); for (i = 0; i < n; i++) { if(ch[i] == 'x') flag++; else flagm++; } if(flag > flagm) { k = flag - flagm; for(j = 0; j < k; j++) printf("x"); } else if(flagm > flag) { k = flagm - flag; for(j = 0; j < k; j++) { printf("y"); } } else continue; printf("\n"); } return 0;}
阅读全文
0 0
- Code Parsing CodeForces
- B. Code Parsing
- hdu B. Code Parsing
- B. Code Parsing
- Clang AST parsing for automated code generation
- Codeforces ZeptoLab Code Rush 2015
- CodeForces 543A-Writing Code
- 【codeforces 765B】Code obfuscation
- Android: Simplified source code for parsing and working with XML data and web services in Android
- Codeforces 420 C. Bug in Code
- codeforces 421D bug in code
- 【codeforces ZeptoLab Code Rush 2015】ABCD题解
- Writing Code - CodeForces 543 A dp
- Codeforces 543A. Writing Code DP
- Codeforces 544C Writing Code(背包)
- CodeForces 543A Writing Code(DP)
- codeforces 543A Writing Code (dp)
- codeforces #320 Writing Code (完全背包)
- Java Spring 编码总结(部分)
- memcached-java客户端xmemcached使用总结 & 与Spring 集成
- Java_面向对象05 static关键字
- 关于解决DevExpress用DevExpress patch工具破解后经常弹出试用框的问题
- jquery操作select(option)的取值,设置和选中
- Code Parsing CodeForces
- [python]获取路径
- ovirt-node 之build分析
- 2018 网易
- Centos 7.0下面安装Mysql5.7.18
- 习题 6.5 将一个数组中的值按逆序重新存放。例如,原来顺序为8,6,5,4,1。要求改为1,4,5,6,8。
- Hydra 8.4/8.5新增功能
- 目标检测--Focal Loss for Dense Object Detection
- python 实现全角半角的相互转换