WOJ1166-Is There Any Prefix?
来源:互联网 发布:淘宝如何拒绝延期 编辑:程序博客网 时间:2024/06/05 13:58
给定一组二进制串,判断是否其中有一串是另外某一串的前缀。对于两个相同的串,我们规定两串相互不为前缀。
例如:10, 010, 0100, 0010, 1010
其中,10是1010的前缀
输入格式
输入有多组数据,每一组数据的第一行为一个整数N,接下来为N个二进制串,每一个串一行。每个二进制串最少有一个比特,而最多有10个比特。每两组输入间有一行空格。N=0时程序结束。
输出格式
对于一组数据,若有某串为另一串的前缀则输出Exist!,否则输出None!
样例输入
5100100100001010104000110110
样例输出
Exist!None!
#include<cstdio>#include<cstdlib>#include<cstring>#include<iostream> #include<algorithm>using namespace std;char str[11];string s[1025];int cmp (char *a, char *b){return strcmp(a,b);}int main(){int N,i,j;while (scanf("%d", &N) == 1 && N > 0) {for (i = 0; i < N; i++){scanf("%s", str);s[i] = str;}sort(s, s + N);for (i = 1; i < N; i++) {j = i - 1;if (strncmp(s[i].c_str(),s[j].c_str(),min(s[i].size(),s[j].size()))==0&&s[i].size()!=s[j].size())break;}if(i==N)printf("None!\n");elseprintf("Exist!\n");}return 0;}
阅读全文
0 0
- WOJ1166-Is There Any Prefix?
- Is there any widget lifecycle events
- Is there any difference between List x; and List x();?
- Is there any datasheet,specification for adreno,krait
- Is-there-any-way-to-prevent-an-android-app-from-being-removed
- Q:Is there any way to define what the "Open Resource" dialog in Eclipse should show?
- Microsoft Office Excel cannot open or save any more documents because there is not enough available
- Is there any best way to reduce the size of ibdata in mysql.?
- Is there any way to define a min and max value for edittext in android?
- English---There is / There are
- Is there anybody in there?
- IDEA There is no configured/running web-servers found! Please, run any web-configuration and hit the
- where there is will,there is life
- there weren't any in sight
- there is nothing
- there is a reason
- there is nothing....
- Given an array of size N in which every number is between 1 and N, determine if there are any dupli
- ImportError: libmkldnn.so.0: cannot open shared object file: No such file or directory
- 51nod 1282 时钟(哈希+最小表示法)
- 微信公众平台获取access_token和极速发票源码JAVA
- form表单提交时,触发校验
- 了解自己电脑的大小端模式
- WOJ1166-Is There Any Prefix?
- jQuery基础知识总结
- TF-IDF教程
- 更换mysql-connector-java-6.0.5jar包后程序出现的两个异常及解决方法
- linux系统最最最最常用的操作指令
- 记录PHP中常用函数
- nyoj-2359 巴什博弈?(模板)
- BroadcastReceiver
- PyCharm中Python的“ ModuleNotFoundError ”