A. Alex and broken contest

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.

Input
The only line contains string from lowercase and uppercase letters and “_” symbols of length, not more than 100 — the name of the problem.

Output
Print “YES”, if problem is from this contest, and “NO” otherwise.

Examples
input
Alex_and_broken_contest
output
NO
input
NikitaAndString
output
YES
input
Danil_and_Olya
output
NO

题解:

熟悉C++的话很快就能AC,做题还是不够细心,没有考虑到字符串中出现两个一样的名字的情况。
如 Nikita_Nikita 这组数据

代码:

#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
using namespace std;

const int maxn = 150;
string temp[]= {"Danil", "Olya", "Slava", "Ann", "Nikita"};
string str;

int main()
{
    cin>>str;
    int count=0;
    for(int i=0;i<5;i++)
    {
      size_t pos = str.find(temp[i],0);
      while(pos != string::npos)
      {
         count++;
         pos = str.find(temp[i],pos+1);
      }
    }

    if(count==1) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
教务工具箱v3.0包括成绩统计、成绩分段、多排表、表格比较与填充、检测同列重复值、考场编排助手、转换座位表、批量导入图片、批量读取文件名、文件批量改名、表格数据合成等在学生数据分析、处理中常用的多个工具,适用于Miscrosoft Office Excel 2000/2003/2007,操作系统为Windows2000/XP/2003/7。安装目录内附有帮助文档和样表供参阅。 本程序是教务工具集系列版本的全新升级版。程序运行速度更快,功能更多,安装及操作更方便。在系统没有关闭的情况下,用户可以任意修改表格中的数据,这一点更是旧版所不能比拟的。 提示:360等极少数杀毒软件可能会将本程序误报为有毒。在此,作者郑重声明,本程序绝对不含有病毒,用户可以放心安装。如果用户在安装时遇到误报有毒的情况可以点击杀毒软件界面上的“信任此文件”等类似按钮或者直接关闭杀毒软件,然后继续安装。 安装方法:如果是首次安装,双击安装文件即可;如果是卸载后重装,则找到安装目录中的文件“安装.bat”双击即可(除非你已经删除了程序文件)。安装成功后在Excel的主菜单栏的右边会增加一个名为“教务工具箱”的按钮,单击此按钮即可启动本系统。 卸载方法: 1、找到并打开安装目录。本系统默认的安装目录是“C:\Program Files\教务工具箱”。 2、双击名称为“卸载”的文件,即可完成卸载。卸载后程序文件可用手工删除。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值