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.
The 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.
Output "YES", if the string is a pangram and "NO" otherwise.
12
toosmallword
NO
35
TheQuickBrownFoxJumpsOverTheLazyDog
YES
http://codeforces.com/contest/520/problem/B#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<vector>
#include<cmath>
#include<stdlib.h>
#include<iomanip>
#include<list>
#include<deque>
#include<map>
#include <stdio.h>
#include <queue>
#include <stack>
#define maxn 10000+5
#define ull unsigned long long
#define ll long long
#define reP(i,n) for(i=1;i<=n;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define cle(a) memset(a,0,sizeof(a))
#define mod 90001
#define PI 3.141592657
#define INF 1<<30
const ull inf = 1LL << 61;
const double eps=1e-5;
using namespace std;
bool cmp(int a,int b)
{
return a>b;
}
int a[27];
int main()
{
#ifndef ONLINE_JUDGE
//freopen("in.txt","r",stdin);
#endif
//freopen("out.txt","w",stdout);
int n,i,mark;
char c;
cin>>n;
cle(a);mark=0;
for(i=1;i<=n;i++)
{
cin>>c;
if(c<='z'&&c>='a')
a[c-'a']++;
else a[c-'A']++;
}
for(i=0;i<26;i++)
if(a[i]==0)
{
cout<<"NO"<<endl;mark=1;break;
}
if(!mark)
cout<<"YES"<<endl;
return 0;
}
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at some point the number stops being positive, the device breaks down. The display can show arbitrarily large numbers. Initially, the display shows number n.
Bob wants to get number m on the display. What minimum number of clicks he has to make in order to achieve this result?
The first and the only line of the input contains two distinct integers n and m (1?≤?n,?m?≤?104), separated by a space .
Print a single number — the minimum number of times one needs to push the button required to get the number m out of number n.
4 6
2
10 1
9
In the first example you need to push the blue button once, and then push the red button once.
In the second example, doubling the number is unnecessary, so we need to push the blue button nine times.
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<vector>
#include<cmath>
#include<stdlib.h>
#include<iomanip>
#include<list>
#include<deque>
#include<map>
#include <stdio.h>
#include <queue>
#include <stack>
#define maxn 10000+5
#define ull unsigned long long
#define ll long long
#define reP(i,n) for(i=1;i<=n;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define cle(a) memset(a,0,sizeof(a))
#define mod 90001
#define PI 3.141592657
#define INF 1<<30
const ull inf = 1LL << 61;
const double eps=1e-5;
using namespace std;
struct node
{
int val;
ll dist;
};
bool cmp(int a,int b)
{
return a>b;
}
queue<node>q;
node v,w;
int n,m,ans;
int vis[10000]={0};
void bfs()
{
int mark=0;
node u;
u.val=n;
u.dist=0;
q.push(u);
while(!q.empty())
{
u=q.front();q.pop();
if(u.val==0)continue;
if(u.val==m){printf("%d\n",u.dist);mark=1;break;}
w.val=u.val-1,w.dist=u.dist+1;
if(w.val>0&&!vis[w.val])
{
vis[w.val]=1;
q.push(w);
}
v.val=u.val*2,v.dist=u.dist+1;
if(v.val<=10000&&!vis[v.val])
{
vis[v.val]=1;
q.push(v);
}
}
if(!mark)cout<<100000<<endl;
}
int main()
{
#ifndef ONLINE_JUDGE
//freopen("in.txt","r",stdin);
#endif
//freopen("out.txt","w",stdout);
cin>>n>>m;
while(!q.empty())q.pop();
bfs();
return 0;
}