A Text Volume
题面:
You are given a text of single-space separated words, consisting of small and capital Latin letters.
Volume of the word is number of capital letters in the word. Volume of the text is maximum volume of all words in the text.
Calculate the volume of the given text.
Input
The first line contains one integer number n (1?≤?n?≤?200) — length of the text.
The second line contains text of single-space separated words s1,?s2,?…,?si, consisting only of small and capital Latin letters.
Output
Print one integer number — volume of text.
input
7
NonZERO
output
5
input
24
this is zero answer text
output
0
input
24
Harbour Space University
output
1
题目大意:
对于每一个数据,有一个数字代表下一行的字符串的长度。
一个字符串里可能有很多个单词,问在这其中的单词里,大写字母最多的单词中有多少个大写字母。
大致思路:
纯水题,记录一下已经读进去的字符串长度,到了n直接跳出。
每一个单词扫一遍,记录大写字母的个数。与记录的最大值取一个max
然后输出结果就可以了。
代码:
#include<bits/stdc++.h>
using namespace std;
int main()
{ios::sync_with_stdio(false);//freopen("in.txt","r",stdin);int n,len=0,maxn=0,cnt;char str[210];cin>>n;while(cin>>str){cnt=0;int l=strlen(str);for(int i=0;i<l;++i)if(isupper(str[i]))cnt++;maxn=max(maxn,cnt);len+=l;if(len>=n)break;len++;}cout<<maxn<<endl;return 0;
}
B Flag of Berland
题面:
The flag of Berland is such rectangular field n?×?m that satisfies following conditions:
Flag consists of three colors which correspond to letters ‘R’, ‘G’ and ‘B’.
Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color.
Each color should be used in exactly one stripe.
You are given a field n?×?m, consisting of characters ‘R’, ‘G’ and ‘B’. Output “YES” (without quotes) if this field corresponds to correct flag of Berland. Otherwise, print “NO” (without quotes).
Input