Car Plates Competition

Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 382    Accepted Submission(s): 82

Problem Description
Martin and Isa are very competitive. The newest competition they have created is about looking at the plates of the cars. Each time one of them sees a car plate in the streets, he or she sends to the other an SMS message with the content of that plate; the one who has seen the newest plate is in the lead of the game. As the Automobile Car Management (ACM) office assigns the plates sequentially in increasing order, they can compare them and find out who is the winner.

Martin has a very smart eye and he has stayed on the lead for several weeks. Maybe he keeps looking at the streets instead of working, or maybe he stays all day in front of car selling companies waiting for new cars to go out with new plates. Isa, tired of being always behind, has written a program that generates a random plate, so the next time

Martin sends a message to her, she will respond with this generated plate. In this way, she hopes to give Martin a hard time trying to beat her. However, Martin has grown suspicious, and he wants to determine if Isa actually saw a car with the plate she sent or not. This way, he will know if Isa is in the lead of the game.

He knows some facts about the plates assigned by the ACM:
●Each plate is a combination of 7 characters, which may be uppercase letters (A-Z), or digits (0-9).
●There exists two kinds of plate schemes: the old one, used for several years, and the new one which has been in use for some months, when the combinations of the old one were exhausted.
●In the old scheme, the first three characters were letters, and the last four were digits, so the plates run from AAA0000 to ZZZ9999.
●In the new scheme, the first five characters are letters, and the last two are digits. Unfortunately the chief of ACM messed up with the printing system while he was trying to create a poster for his next campaign for mayor, and the printer is not able to write the letters A, C, M, I, and P. Therefore, in this new scheme, the first plate is BBBBB00, instead of AAAAA00.
●The plates are assigned following a sequential order. As a particular case, the last plate from the old scheme is followed by the first plate from the new scheme.

As Isa is not aware of all of this, she has just made sure that her random generator creates a combination consisting of seven characters, where the first three characters are always uppercase letters, the last two characters are always digits, and each one of the fourth and fifth characters may be an uppercase letter or a digit (possibly generating an illegal combination, but she has not much time to worry about that).

Of course, Martin will not consider Isa the winner if he receives an illegal combination, or if he receives a legal plate, but equal to or older than his. But that's not all of it. Since Martin knows that new plates are not generated too fast, he will not believe that Isa saw a car with a plate newer than the one he sent, but sequentially too far. For example, if Martin sends DDDDD45, and receives ZZZZZ45, he will not believe that Isa saw a car with that plate, because he knows that the ACM couldn't have printed enough plates to get to ZZZZZ45 in the time he received that answer.

So, Martin has decided to consider Isa the winner only if he receives a legal plate, newer than his, and older than or equal to the C-th consecutive plate after the one he sent. He calls C his confidence number. For example, if Martin sends ABC1234, and his confidence number is 6, he will think that Isa is the winner only if he receives any plate newer than ABC1234, but older than or equal to ABC1240.

 
Input
The input contains several test cases. Each test case is described in a single line that contains two strings SM and SI , and an integer C, separated by single spaces. SM is the 7-character string sent by Martin, which is always a legal plate. SI is the 7-character string answered by Isa, which was generated using her random generator. C is Martin's confidence number (1 <= C <= 109).
The end of input is indicated by SM = SI = "*" and C = 0.
 
Output
For each test case, output a single line with the uppercase character "Y".
if, according to Martin, Isa is the winner, and with the uppercase character "N" otherwise.
 
Sample Input

ABC1234 ABC1240 6
ABC1234 ABC1234 6
ACM5932 ADM5933 260000
BBBBB23 BBBBC23 100
BBBBB23 BBBBD00 77
ZZZ9997 ZZZ9999 1
ZZZ9998 BBBBB01 3
ZZZZZ95 ZZZZZ99 10
BBBBB23 BBBBB22 5
* * 0

Sample Output

Y
N
N
N
Y
N
Y
Y
N

 
Source
 
Recommend
lcy
/**
题意:给出两个串按照题意,看是否b串比a串大并且不能大于n
**/
#include <iostream>
#include <algorithm>
#include <string.h>
#include <cmath>
#include <stdio.h>
#include <queue>
using namespace std;
char mm[] = {"ACMIP"};
char a[];
char b[];
__int64 n;
int check(char c[])
{
int len = strlen(c);
bool isok2 = true;
bool isok1 = true;
for(int i=;i<;i++)
{
if(c[i] <'A' || c[i] >'Z')
{
isok1 = false;
break;
}
}
for(int i=;i<;i++)
{
if(c[i] <'' || c[i] >'')
{
isok1 = false;
break;
}
}
for(int i=;i<;i++)
{
if(c[i] <'B' || c[i] > 'Z' || c[i] == 'C' || c[i] == 'M' || c[i] == 'I' || c[i] == 'P')
{
isok2 = false;
break;
}
}
for(int i=;i<;i++)
{
if(c[i] <'' || c[i] > '')
{
isok2 = false;
break;
}
}
if(isok1) return ;
else if(isok2) return ;
return ;
}
__int64 cal_old(char s[])
{
__int64 sum = ;
for(int i=;i<;i++)
{
sum = sum * + (s[i]-'A');
}
for(int i=;i<;i++)
{
sum = sum * + (s[i] -'');
}
return sum;
}
char dir[] = {"BDEFGHJKLNOQRSTUVWXYZ"};
int cal_new(char s[])
{
__int64 sum = ;
for(int i=;i<;i++)
{
int res = -;
while(s[i] != dir[++res]);
sum = sum * + res;
}
int tmp = ;
for(int i=;i<;i++)
{
tmp = tmp* + (s[i] - '');
}
sum *= ;
sum += tmp;
sum = sum + cal_old("ZZZ99999") + ;
return sum;
}
int main()
{
//freopen("in.txt","r",stdin);
while(~scanf("%s %s %d",a,b,&n))
{
getchar();
if(a[] == '*' && b[] == '*' && n == ) break;
int res = check(a);
int tmp = check(b);
if(res == || tmp == )
{
printf("N\n");
continue;
}
__int64 sum_a = ;
__int64 sum_b = ;
if(res == )
sum_a = cal_old(a);
else
sum_a = cal_new(a);
if(tmp == )
sum_b = cal_old(b);
else
sum_b = cal_new(b);
//cout<<sum_a<<" "<<sum_b<<endl;
if(sum_b > sum_a && sum_a + n >= sum_b)
printf("Y\n");
else
printf("N\n");
}
return ;
}

HDU-1934的更多相关文章

  1. HDU 1934 树状数组 也可以用线段树

    http://acm.hdu.edu.cn/showproblem.php?pid=1394 或者是我自己挂的专题http://acm.hust.edu.cn/vjudge/contest/view. ...

  2. HDU 1934 特殊数字

    有两种车牌号.让你判断第二种是不是在第一种之后且在第一种出Kth之前的车牌号. 本解中是把前面的字母看成一位十进制的数.自己是一个26或者21进制的数.如果比较时有两种.那么第一种和第一种的最后一个比 ...

  3. HDU 5643 King's Game 打表

    King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...

  4. POJ 3653 &amp; ZOJ 2935 &amp; HDU 2722 Here We Go(relians) Again(最短路dijstra)

    题目链接: PKU:http://poj.org/problem? id=3653 ZJU:problemId=1934" target="_blank">http ...

  5. poj和hdu部分基础算法分类及难度排序

    最近想从头开始刷点基础些的题,正好有个网站有关于各大oj的题目分类(http://www.pythontip.com/acm/problemCategory),所以写了点脚本把hdu和poj的一些题目 ...

  6. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  7. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  8. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  9. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  10. HDU 4006The kth great number(K大数 +小顶堆)

    The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64 ...

随机推荐

  1. bzoj4518: [Sdoi2016]征途(DP+决策单调性分治优化)

    题目要求... 化简得... 显然m和sum^2是已知的,那么只要让sigma(si^2)最小,那就变成了求最小平方和的最小值,经典的决策单调性,用分治优化即可. 斜率优化忘得差不多就不写了 #inc ...

  2. 2017-7-19-每日博客-关于Linux下的CentOS中文件夹基本操作命令.doc

    CentOS中文件夹基本操作命令 文件(夹)查看类命令 ls--显示指定目录下内容 说明:ls 显示结果以不同的颜色来区分文件类别.蓝色代表目录,灰色代表普通文件,绿色代表可执行文件,红色代表压缩文件 ...

  3. c++11新特性之nullptr

    在c++11中,nullptr可完全代替NULL.  然而NULL和nullptr还是稍有不同,NULL可被转化为int类型,而nullptr不能.因此nullptr对NULL在进行模板推导或者函数重 ...

  4. Moodle配置

    Moodle配置 1.   内部设置 在 Moodle 站点管理员界面中有一系列的配置页面(可以从'设置' 块中访问 '网站管理'区).这里有一些重要的系统设置,你需要进行检查. 根据提示信息并结合实 ...

  5. CSS3 :empty 选择器

    这可是个好东西,我也是这个星期才发现的,下面我们来说具体功能. <!DOCTYPE html> <html> <head> <meta charset=&qu ...

  6. iBATIS事务处理

    一:问题 最近发现了我们自己的项目的事务的处理根本就是行不通的,也因此我自己又去看了下有关事务的处理,算是有了个大致的了解吧,先说说我们最初的配置吧. 二:内容 (1):使用iBatis的事务管理 S ...

  7. 洛谷 P1044 栈

    题目背景 栈是计算机中经典的数据结构,简单的说,栈就是限制在一端进行插入删除操作的线性表. 栈有两种最重要的操作,即pop(从栈顶弹出一个元素)和push(将一个元素进栈). 栈的重要性不言自明,任何 ...

  8. Hexo&Github-Pages搭建个人博客

    some基础知识 hexo hexo是一款基于Node.js的静态博客框架 github-pages说明 github有两种主页,一种是github-page(个人主页),一种是项目主页,本教程针对个 ...

  9. MyBatis框架的使用及源码分析(七) MapperProxy,MapperProxyFactory

    从上文<MyBatis框架中Mapper映射配置的使用及原理解析(六) MapperRegistry> 中我们知道DefaultSqlSession的getMapper方法,最后是通过Ma ...

  10. jmeter进行http压力测试(图文小教程)

    下载地址:http://jmeter.apache.org/download_jmeter.cgi JMeter基于Java开发,需要系统有安装JDK环境.解压后进入bin目录,点击jmeter.ba ...