A. Alex and broken contest
来源:互联网 发布:sql 累加函数 编辑:程序博客网 时间:2024/06/05 09:34
One day Alex was creating a contest about his friends, but accidentally deleted it. Fortunately, all the problems were saved, but now he needs to find them among other problems.
But there are too many problems, to do it manually. Alex asks you to write a program, which will determine if a problem is from this contest by its name.
It is known, that problem is from this contest if and only if its name contains one of Alex's friends' name exactly once. His friends' names are "Danil", "Olya", "Slava", "Ann" and "Nikita".
Names are case sensitive.
The only line contains string from lowercase and uppercase letters and "_" symbols of length, not more than 100 — the name of the problem.
Print "YES", if problem is from this contest, and "NO" otherwise.
Alex_and_broken_contest
NO
NikitaAndString
YES
Danil_and_Olya
NO
解题说明:此题是一道字符串查找题目,按照题目意思找出包含指定子串的字符串即可。
#include<cstdio>#include<iostream>#include<string>#include<cstring>#include<cmath>using namespace std;string str[] = { "Danil", "Olya", "Slava", "Ann" , "Nikita" };string S;int main(){cin >> S;int flag = 0;for (int i = 0; i < 5; i++) {for (int j = 0; j < S.size(); j++) {if (S.substr(j, str[i].size()) == str[i]){flag++;}}}if (flag == 1){puts("Yes\n");}else{puts("No\n");}return 0;}
- A. Alex and broken contest
- A. Alex and broken contest
- Codeforces 877 A Alex and broken contest
- Codeforces Round #442 (Div. 2) A. Alex and broken contest
- codeforces 442 A. Alex and broken contest(水题)
- Codeforces Round #442 (Div. 2) A Alex and broken contest
- CF#877 A. Alex and broken contest(KMP)
- Codeforces Round #442 (Div. 2) A. Alex and broken contest
- Alex and broken contest Codeforces Round #442
- Codeforces Round #442 (Div. 2) A. Alex and broken contest,B
- A. GukiZ and Contest
- 【2015-2016 ACM-ICPC, NEERC, Northern Subregional Contest A】【水题 讨论】Alex Origami Squares 矩形内置三个最大正方形
- 1.a contest between satisfaction and temptation
- CodeForces-551A GukiZ and Contest
- coderforce 551A - GukiZ and Contest
- 【74.89%】【codeforces 551A】GukiZ and Contest
- codeforces 551A GukiZ and Contest
- D - A Broken Calculator
- Material Design学习之RecyclerView(更强大的滚动控件)(4)
- 说说搜索引擎中的人工干预
- C语言利用栈判断字符串是否为回文
- CString或宽字符串转换成10进制整数的两种办法
- 枚举类
- A. Alex and broken contest
- 欢迎使用CSDN-markdown编辑器
- 以太坊代币智能合约底层开发教程Geth基本命令
- Ububtu14.04 配置caffe+cuda
- 数据结构实验之二叉树二:遍历二叉树
- union 和 union all 的区别
- Phoenix 索引生命周期
- 新研究旨在用“黑箱”算法解决人工智能偏差问题
- 神经学家探寻:机器如何拥有意识!