Read Phone Number

Time Limit:1000MS     Memory Limit:64000KB     64bit IO Format:%lld & %llu

Description

Do you know how to read the phone numbers in English? Now let me tell you.

For example, In China, the phone numbers are 11 digits, like: 15012233444. Someone divides the numbers into 3-4-4 format, i.e. 150 1223 3444. While someone divides the numbers into 3-3-5 format, i.e. 150 122 33444. Different formats lead to different ways to read these numbers:

150 1223 3444 reads one five zero one double two three three triple four.

150 122 33444 reads one five zero one double two double three triple four.

Here comes the problem:

Given a list of phone numbers and the dividing formats, output the right ways to read these numbers.

Rules:

Single numbers just read them separately.

2 successive numbers use double.

3 successive numbers use triple.

4 successive numbers use quadruple.

5 successive numbers use quintuple.

6 successive numbers use sextuple.

7 successive numbers use septuple.

8 successive numbers use octuple.

9 successive numbers use nonuple.

10 successive numbers use decuple.

More than 10 successive numbers read them all separately.

Input

The first line of the input gives the number of test cases, T(1 ≤ T ≤ 100).

T test cases follow. Each line contains a phone number N(1 ≤ length of N ≤ 100) and the dividing format F, one or more positive integers separated by dashes (-), without leading zeros and whose sum always equals the number of digits in the phone number.

Output

For each test case, output one line containing "Case #x: y", where  x is the case number (starting from 1) and  y is the reading sentence in English whose words are separated by a space.

Sample Input

3
15012233444 3-4-4
15012233444 3-3-5
12223 2-3

Sample Output

Case #1: one five zero one double two three three triple four
Case #2: one five zero one double two double three triple four
Case #3: one two double two three
题意样例输入输出就能看懂,注意10个以上数字要单独输出,是个字符串大模拟。
#include <iostream>
#include <cstdio>
#include <string.h>
using namespace std;
char data[][]={"double","triple","quadruple","quintuple","sextuple",
"septuple","octuple","nonuple","decuple"};
char aa[][]={"zero","one","two","three","four","five","six","seven","eight","nine","decuple"};
int main()
{
int t,cas=;
scanf("%d",&t);
while(t--)
{
char c[],d[];
scanf("%s",c);
scanf("%s",d);
int len1=strlen(c);
int len2=strlen(d);
int a[];
for(int i=;i<len1;i++)
a[i]=c[i]-'';
int fen[],cnt=,tmp=;
printf("Case #%d:",cas++);
for(int i=;i<len2;i++)
{
if(d[i]!='-')
{
tmp=tmp*;
tmp+=d[i]-'';
}
else
{
fen[cnt++]=tmp;
tmp=;
}
}
if(tmp) fen[cnt++]=tmp;
//for(int i=0;i<cnt;i++)
//cout<<fen[i]<<endl;
int b=;
int sum=;
for(int i=;i<cnt;i++)
{
b=;
for(int j=sum;j<sum+fen[i];j++)
{
if(j+<sum+fen[i])
{
if(a[j]==a[j+])
b++;
else
{
if(b==)
{
cout<<" "<<aa[a[j]];
}
else if(b>&&b<=)
{
cout<<" "<<data[b-]<<" "<<aa[a[j]];
b=;
}
else
{
for(int k=;k<b;k++)
cout<<" "<<aa[a[j]];
b=;
}
}
}
else //最后一个字符了
{
if(b==)
{
cout<<" "<<aa[a[j]];
}
else if(b>&&b<=)
{
cout<<" "<<data[b-]<<" "<<aa[a[j]];
b=;
}
else
{
for(int k=;k<b;k++)
cout<<" "<<aa[a[j]];
b=;
}
}
}
sum+=fen[i];
}
cout<<endl;
}
return ;
}
 

ACdream 1188 Read Phone Number (字符串大模拟)的更多相关文章

  1. 【字符串大模拟】潜伏者—— NOIP2009原题

    洛谷连接 就一道黄题没啥可以说的……就是要细心…… 学到了神奇的优化 ios::sync_with_stdio(false); cin优化,能跑的比scanf快!棒!(不过要开std) 这题真的还挺简 ...

  2. 2016ACM-ICPC网络赛北京赛区 1001 (trie树牌大模拟)

    [题目传送门] 1383 : The Book List 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 The history of Peking University ...

  3. NOIP2017 时间复杂度 大模拟

    再写一道大模拟题. 由于是限时写的,相当于考场代码,乱的一批. 题目链接:P3952 时间复杂度 先记几个教训: 字符串形式的数字比较大小老老实实写函数,字典序都搞错几次了 栈空的时候不但pop()会 ...

  4. Codeforces 730L - Expression Queries(大模拟)

    Codeforces 题面传送门 & 洛谷题面传送门 大模拟(?)+阿巴细节题,模拟赛时刚了 3h 最后因为某个细节写挂 100->40/ll/ll(下次一定不能再挂分了啊 awa) 首 ...

  5. HDU 5920 Ugly Problem 高精度减法大模拟 ---2016CCPC长春区域现场赛

    题目链接 题意:给定一个很大的数,把他们分为数个回文数的和,分的个数不超过50个,输出个数并输出每个数,special judge. 题解:现场赛的时候很快想出来了思路,把这个数从中间分为两部分,当位 ...

  6. AC日记——神奇的幻方 洛谷 P2615(大模拟)

    题目描述 幻方是一种很神奇的N*N矩阵:它由数字1,2,3,……,N*N构成,且每行.每列及两条对角线上的数字之和都相同. 当N为奇数时,我们可以通过以下方法构建一个幻方: 首先将1写在第一行的中间. ...

  7. Bzoj1972: [Sdoi2010]猪国杀 题解(大模拟+耐心+细心)

    猪国杀 - 可读版本 https://mubu.com/doc/2707815814591da4 题目可真长,读题都要一个小时. 这道题很多人都说不可做,耗时间,代码量大,于是,本着不做死就不会死的精 ...

  8. (大模拟紫题) Luogu P1953 易语言

    原题链接:P1953 易语言 (我最近怎么总在做大模拟大搜索题) 分别处理两种情况. 如果只有一个1或0 直接设一个cnt为这个值,每次输入一个新名字之后把数字替换成cnt,最后cnt++即可. 注意 ...

  9. [CSP-S模拟测试]:引子(大模拟)

    题目描述 网上冲浪时,$Slavko$被冲到了水箱里,水箱由上而下竖直平面.示意图如下: 数字$i$所在的矩形代表一个编号为$i$的水箱.1号水箱为水箱中枢,有水管连出.除了$1$号水箱外,其他水箱上 ...

随机推荐

  1. float,double,decimal使用讨论

    注意:有效位:小数点前后的全部数字,不包括小数点在内 float:浮点型,含字节数为4,32bit,数值范围为-3.4E38~3.4E38(7个有效位) double:双精度实型,含字节数为8,64b ...

  2. JSON前端页面解析

    JSON 指的是 JavaScript 对象表示法(JavaScript Object Notation) JSON 是轻量级的文本数据交换格式 JSON 独立于语言 * JSON 具有自我描述性,更 ...

  3. 在excel批量更改单元格类型后的批量刷新显示

    把E的东西变成完整显示 解决办法: 选中所需要更改的整列数据------>菜单栏的数据选项------>分列

  4. Json序列化对象

    之前都是用的二进制的序列化方法,是.net自带的,但是最常用到的还是Json序列化 (1)只需要调用 Newtonsoft.Json.dll 即可 public class JsonTools { / ...

  5. Conjugate prior relationships

    Conjugate prior relationships The following diagram summarizes conjugate prior relationships for a n ...

  6. Struts2拦截器的应用

    拦截器类 public class AdminInterceptor extends AbstractInterceptor { private static final long serialVer ...

  7. 王垠:完全用Linux工作

    来自: Zentaur(alles klar) 录一篇旧文 作者:王垠 完全用Linux工作,抛弃windows 我已经半年没有使用 Windows 的方式工作了.Linux 高效的完成了我所有的工作 ...

  8. git曲线

    git 更新牵涉到三个地方的内容: ?? (pull下来的) 正在编辑的目录, 即工作空间; 本地的仓库;   (这个动作叫 : commit) github.com上的服务器即 refs (这个动作 ...

  9. meta中的viewport指令

    网页手机wap2.0网页的head里加入下面这条元标签,在iPhone的浏览器中页面将以原始大小显示,并不允许缩放. <meta name="viewport" conten ...

  10. string,const char*,char*之间的相互转换

    1. string转const char* string s = "abc"; const char* c_s = s.c_str(); 2. const char*转string ...