Uva 12602 - Nice Licence Plates
#include<bits/stdc++.h>
#define pf printf
#define sf scanf
using namespace std;
int ar[30+5];
void keep()
{
for(int i=65, j=0; i<91; i++,j++)
{
ar[i] = j;
}
//for(int i=65;i<=90;i++)cout << ar[i] << " ";
}
int getnum(char x[])
{
int len=3, sum=0;
int p=2;
for(int i=0; i<3; i++)
{
sum += ar[x[i]] * powl(26,p);
p--;
}
//cout << sum;
return sum;
}
int main()
{
keep();
int t;
char ch[9+5], s[5],c;
sf("%d",&t);
while(t--)
{
getchar();
int n;
for(int i=0;i<3;i++)
{
sf("%c",&s[i]);
}
sf("%c",&c);
sf("%d",&n);//cout << n;
if(abs(getnum(s) - n) < 101)
{
cout << "nice" << endl;
}
else
{
cout << "not nice" << endl;
}
}
return 0;
}
#define pf printf
#define sf scanf
using namespace std;
int ar[30+5];
void keep()
{
for(int i=65, j=0; i<91; i++,j++)
{
ar[i] = j;
}
//for(int i=65;i<=90;i++)cout << ar[i] << " ";
}
int getnum(char x[])
{
int len=3, sum=0;
int p=2;
for(int i=0; i<3; i++)
{
sum += ar[x[i]] * powl(26,p);
p--;
}
//cout << sum;
return sum;
}
int main()
{
keep();
int t;
char ch[9+5], s[5],c;
sf("%d",&t);
while(t--)
{
getchar();
int n;
for(int i=0;i<3;i++)
{
sf("%c",&s[i]);
}
sf("%c",&c);
sf("%d",&n);//cout << n;
if(abs(getnum(s) - n) < 101)
{
cout << "nice" << endl;
}
else
{
cout << "not nice" << endl;
}
}
return 0;
}
Comments
Post a Comment