Alex’s Game(I)
来源:互联网 发布:江西省网络作家协会 编辑:程序博客网 时间:2024/06/04 01:24
F - Alex’s Game(I)
Time Limit:1000MS Memory Limit:65535KB 64bit IO Format:%I64d & %I64uDescription
Alex likesto play with one and zero!One day he gets an empty string.So our cute boy wants to add one and zero in it. Every time he will add ‘01’in the string at any position and then get a new string.For example:if the string is “01” now ,he can get “0101” or “0011,Now give you a string that is Alex has get,you need to answer whether the string is legal?
Input
First is a integer n(n<=100)
Next contains n lines .Every line is a string whose legth is no more than 1000.
Next contains n lines .Every line is a string whose legth is no more than 1000.
Output
For each case output "YES" in a single line if it’s legal.
Or you need to output “NO”;
Or you need to output “NO”;
Sample Input
3010101100011
Sample Output
YESNOYES
Hint
无
这个题很简单,对于字符串里的所有的0,只要0前面的1的个数不会大于0的个数就可以说明所有插入的字符串都是01排列了。
#include<stdio.h>#include<string.h>int main(){ int n; char a[1005]; scanf("%d",&n); while(n--) { int flag=0; scanf("%s",a); for(int j=0; j<strlen(a); j++) { if(a[j]=='0') { int sum1=0,sum2=0; for(int k=0; k<j; k++) { if(a[k]=='1') sum1++; else sum2++; } if(sum1>sum2) { printf("NO\n"); flag=1; break; } } } if(!flag) printf("YES\n"); } return 0;}
2 0
- Alex’s Game(I)
- Alex’s Game(I)
- NOJ——1627Alex’s Game(II)(尺取)
- NOJ——1628Alex’s Game(III)(DFS+回溯)
- caffe教程翻译:Alex’s CIFAR-10 tutorial, Caffe style
- i-s
- I Love This Game!
- I Love This Game
- I Love This Game
- [LeetCode] Jump Game I
- Jump Game I , II
- FZU:I. Fire Game
- jump game I // II
- Game Study I
- Jump Game I,II
- 1889. Max’s game
- 【poj2348】Euclid's Game
- 10905 - Children's Game
- 4、C语言与画面显示的练习
- 设计模式之观察者设计模式
- 第3章 基本概念小结
- 新年寄语
- STM32之中断与事件---中断与事件的区别
- Alex’s Game(I)
- SQL Server Convert()函数
- cocos2dx 3.1.1 添加cocostudio模块
- 中国企业可以注册的域名有哪些?
- Context中有一个startActivity方法
- leetcode之House Robber
- n*n(n<20,为正奇数)阶方阵(题型二)
- Atmel 官方网站中文版
- Android5.1中联系人新建和保存机制