A. Pangram time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard outputadmin管理员组文章数量:1655682
A word or a sentence in some language is called a pangram if all the characters of the alphabet of this language appear in it at least once. Pangrams are often used to demonstrate fonts in printing or test the output devices.
You are given a string consisting of lowercase and uppercase Latin letters. Check whether this string is a pangram. We say that the string contains a letter of the Latin alphabet if this letter occurs in the string in uppercase or lowercase.
InputThe first line contains a single integer n (1 ≤ n ≤ 100) — the number of characters in the string.
The second line contains the string. The string consists only of uppercase and lowercase Latin letters.
OutputOutput "YES", if the string is a pangram and "NO" otherwise.
Sample test(s) input12 toosmallwordoutput
NOinput
35 TheQuickBrownFoxJumpsOverTheLazyDogoutput
YES
标准水题一枚,先全部转化成小写,然后用个数组做个统计,看看是不是26个字母全有了就行了。
package com.codeforces.algorithm;
import java.io.PrintWriter;
import java.util.*;
public class Pangram {
public static void main(String []args){
Scanner cin = new Scanner(System.in);
PrintWriter cout = new PrintWriter(System.out);
while(cin.hasNext()){
int n = cin.nextInt();
String str = cin.next();
String ptr = str.toLowerCase();
int []num = new int[27];
for(int i=0;i<27;i++) num[i]=0;
for(int i=0;i<ptr.length();i++){
num[ptr.charAt(i)-'a']++;
}
boolean flag=true;
for(int i=0;i<26;i++){
if(num[i]==0){
flag=false;break;
}
}
if(flag){
cout.println("YES");
}
else{
cout.println("NO");
}
cout.flush();
}
cout.close();
}
}
本文标签: codeforcesPangram
版权声明:本文标题:Codeforces Round #295A. Pangram 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dianzi/1729699825a1210472.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论