TeamNames

TeamNames

A certain ICPC regional contest has specific requirements for the names of the competing teams. One of the reasons this is done is so spectators can determine which school each team is from. The requirements for a team name are specified on the website for the region as shown here:

• Each team name must consist of the institution name (greater than 1 character but less than or equal to 8 characters) followed by a hyphen (-) followed by a team name (greater than 0 characters but less than or equal to 24 characters). Please note that spaces are counted as characters.

• Format: INSTITUTION-TEAMNAME INSTITUTION = University name or abbreviation. 1 < length(INSTITUTION ) <= 8. TEAMNAME = Your team name. 1 <= length(TEAMNAME) <= 24.

Write a program that determines if a supplied string is a valid team name for this region.

Input
The input consists of a single line containing a string of characters at least one character long and no more than 80 characters long. The input string will not have any leading or trailing spaces. The INSTITUTION may not contain hyphens (obviously). The TEAMNAME, however, may contain hyphens.

Output
The single output line consists of the word YES if the string represents a valid team name for the region or NO if the string does not represent a valid team name for the region.

Sample Input
Stevens-1

Sample Output
YES

Sample Input 2
INSTITUTION-TEAMNAME

Sample Output 2
NO

Sample Input 3
Dragons

Sample Output 3
NO
题意:输入一串字符串,倘若该字符串中有连字符“-”,并且连字符前的名称大于一个字符但小于或等于八个字符,连字符后的名称大于0个字符但小于或等于24个字符,则输出YES,否则输出NO;
思路:水题,按题意模拟即可。

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	string s;
	getline(cin,s);
	int a,b,c,n;
	a=b=c=0;
	n=s.size();
	for(int i=0;i<n;i++)
	{
		if(s[i]=='-')
		{
			b=i+1;
			break;
		}
	}
	a=b-1;
	c=n-b;
	if(a>1&&a<=8&&c>0&&c<=24)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值