Codeforces 877 A Alex and broken contest
来源:互联网 发布:淘宝e客服怎么开通 编辑:程序博客网 时间:2024/06/04 18:22
题目地址
题意:告诉你一个字符串,问你这个字符串中出现了多少次他5个朋友的名字(”Danil”, “Olya”, “Slava”, “Ann”, “Nikita”),如果就出现一次就输出“YES”,否则为“NO”。
思路:直接按条件暴力搜就好了。
#include <iostream>#include <cstring>#include <string>#include <queue>#include <vector>#include <map>#include <set>#include <cmath>#include <cstdio>#include <algorithm>#include <iomanip>#define N 10#define M 2000010//双倍#define LL __int64#define inf 0x3f3f3f3f3f3f3f3f#define lson l,mid,ans<<1#define rson mid+1,r,ans<<1|1#define getMid (l+r)>>1#define movel ans<<1#define mover ans<<1|1using namespace std;const LL mod = 1000000007;const double eps = 0.001;int main() { cin.sync_with_stdio(false); string str; string list[N]; list[0] = "Danil", list[1] = "Olya", list[2] = "Slava", list[3] = "Ann", list[4] = "Nikita"; while (cin >> str) { int num = 0; for (int i = 0; i < 5; i++) { int cnt = str.find(list[i]); if (cnt != str.npos) { string now = str.substr(cnt + list[i].length()); if (now.find(list[i]) != now.npos) { num++; } num++; } } if (num == 1) { cout << "YES" << endl; } else { cout << "NO" << endl; } } return 0;}
阅读全文
0 0
- Codeforces 877 A Alex and broken contest
- A. Alex and broken contest
- 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
- Codeforces Round #442 (Div. 2) A. Alex and broken contest
- Alex and broken contest Codeforces Round #442
- CF#877 A. Alex and broken contest(KMP)
- Codeforces Round #442 (Div. 2) A. Alex and broken contest,B
- CodeForces-551A GukiZ and Contest
- 【74.89%】【codeforces 551A】GukiZ and Contest
- codeforces 551A GukiZ and Contest
- codeforces#285 A - Contest + B - Misha and Changing Handles
- [水题]Codeforces Round #307 (Div. 2) A.GukiZ and Contest
- Codeforces Round #307 (Div. 2) A. GukiZ and Contest
- CodeForces 551A GukiZ and Contest(模拟)
- CodeForces 501A Contest
- NOIP模拟(20171024)T3 数学
- linux mysql表格大小写的问题
- bzoj4446 小凸玩密室【树形dp】
- 洛谷2119 魔法阵
- Codeforces 855 B Marvolo Gaunt's Ring(dp)
- Codeforces 877 A Alex and broken contest
- 7种失败的职场人
- ViewPager使用中遇到的问题
- NOIP-2014 联合权值
- BZOJ3398 [Usaco2009 Feb]Bullcow 牡牛和牝牛
- MySQL双主一致性架构优化
- HDU
- 编程范式13听课笔记——缓冲区溢出和C++接受可变参数
- BottomTabBar的使用