Codeforces Round #442 (Div. 2) A Alex and broken contest

A. Alex and broken contest
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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


题意 给出四个字符串 求输入的字符串s中 如果有且只有一个字符串包含在s中 那么就输出Yes 反之输出No

用很蠢的方法判断一下

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

int main()
{
	char str[150];
	int D = 0, O = 0, S = 0, A = 0, N = 0;
	scanf("%s", str);
	int l = strlen(str);
	str[l] = str[l + 1] = str[l + 2] = str[l + 3] = str[l + 4] = '0';
	for (int i = 0; i < l; i ++) {
		if (str[i] == 'A' && str[i + 1] == 'n' && str[i + 2] == 'n') {
			A ++;
		}
		if (str[i] == 'O' && str[i + 1] == 'l' && str[i + 2] == 'y' && str[i + 3] == 'a') {
			O ++;
		}
		if (str[i] == 'D' && str[i + 1] == 'a' && str[i + 2] == 'n' && str[i + 3] == 'i' && str[i + 4] == 'l') {
			D ++;
		}
		if (str[i] == 'S' && str[i + 1] == 'l' && str[i + 2] == 'a' && str[i + 3] == 'v' && str[i + 4] == 'a') {
			S ++;
		}
		if (str[i] == 'N' && str[i + 1] == 'i' && str[i + 2] == 'k' && str[i + 3] == 'i' && str[i + 4] == 't' && str[i + 5] == 'a') {
			N ++;
		}
	}
	if (A + O + D + S + N == 1) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	
}


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值