ACdream 1188 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
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 (字符串大模拟)的更多相关文章
- 【字符串大模拟】潜伏者—— NOIP2009原题
洛谷连接 就一道黄题没啥可以说的……就是要细心…… 学到了神奇的优化 ios::sync_with_stdio(false); cin优化,能跑的比scanf快!棒!(不过要开std) 这题真的还挺简 ...
- 2016ACM-ICPC网络赛北京赛区 1001 (trie树牌大模拟)
[题目传送门] 1383 : The Book List 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 The history of Peking University ...
- NOIP2017 时间复杂度 大模拟
再写一道大模拟题. 由于是限时写的,相当于考场代码,乱的一批. 题目链接:P3952 时间复杂度 先记几个教训: 字符串形式的数字比较大小老老实实写函数,字典序都搞错几次了 栈空的时候不但pop()会 ...
- Codeforces 730L - Expression Queries(大模拟)
Codeforces 题面传送门 & 洛谷题面传送门 大模拟(?)+阿巴细节题,模拟赛时刚了 3h 最后因为某个细节写挂 100->40/ll/ll(下次一定不能再挂分了啊 awa) 首 ...
- HDU 5920 Ugly Problem 高精度减法大模拟 ---2016CCPC长春区域现场赛
题目链接 题意:给定一个很大的数,把他们分为数个回文数的和,分的个数不超过50个,输出个数并输出每个数,special judge. 题解:现场赛的时候很快想出来了思路,把这个数从中间分为两部分,当位 ...
- AC日记——神奇的幻方 洛谷 P2615(大模拟)
题目描述 幻方是一种很神奇的N*N矩阵:它由数字1,2,3,……,N*N构成,且每行.每列及两条对角线上的数字之和都相同. 当N为奇数时,我们可以通过以下方法构建一个幻方: 首先将1写在第一行的中间. ...
- Bzoj1972: [Sdoi2010]猪国杀 题解(大模拟+耐心+细心)
猪国杀 - 可读版本 https://mubu.com/doc/2707815814591da4 题目可真长,读题都要一个小时. 这道题很多人都说不可做,耗时间,代码量大,于是,本着不做死就不会死的精 ...
- (大模拟紫题) Luogu P1953 易语言
原题链接:P1953 易语言 (我最近怎么总在做大模拟大搜索题) 分别处理两种情况. 如果只有一个1或0 直接设一个cnt为这个值,每次输入一个新名字之后把数字替换成cnt,最后cnt++即可. 注意 ...
- [CSP-S模拟测试]:引子(大模拟)
题目描述 网上冲浪时,$Slavko$被冲到了水箱里,水箱由上而下竖直平面.示意图如下: 数字$i$所在的矩形代表一个编号为$i$的水箱.1号水箱为水箱中枢,有水管连出.除了$1$号水箱外,其他水箱上 ...
随机推荐
- 模拟Modbus协议问题
问题: 在嵌入式系统开发中,Modbus协议是工业控制系统中广泛应用的一种协议.本题用来简单模拟Modbus协议,只需根据条件生成符合该协议的数据帧,并解析所获取的数据.假设设备使用的协议发送数据格式 ...
- 【uoj222】 NOI2016—区间
http://uoj.ac/problem/222 (题目链接) 题意 有n个区间,当有m个区间有公共部分时,求m个区间长度的最大值与最小值之差的最小值. Solution 线段树+滑动窗口.这道题很 ...
- SSL、TLS协议格式、HTTPS通信过程、RDP SSL通信过程
相关学习资料 http://www.360doc.com/content/10/0602/08/1466362_30787868.shtml http://www.gxu.edu.cn/college ...
- vi显示行号
vi显示行号 :set nu 带行号查看,并不改变文件内容:set nonu 取消带行号查看在每个用户的主目录下,都有一个 vi 的配置文件".vimrc&quo ...
- win10系统安装.net35的命令行方式
有些程序在windows系统中需要安装.net35才能运行,下载太慢了,可以直接在docs窗口直接安装,命令行如下:Dism /online /enable-feature /featurename: ...
- Developing a plugin framework in ASP.NET MVC with medium trust
http://shazwazza.com/post/Developing-a-plugin-framework-in-ASPNET-with-medium-trust.aspx January 7, ...
- Openresty 与 Tengine
Openresty 与 Tengine Openresty和Tengine基于 Nginx 的两个衍生版本,某种意义上他们都和淘宝有关系,前者是前淘宝工程师agentzh主导开发的,后者是淘宝的一个开 ...
- 保存知乎收藏夹功能的NodeJS版本
前两天发现知乎收藏夹中的答案正在不断减少..看来需要保存一下了,但之前别人的方式是用chrome插件(浏览器无法自动保存本地文件)+wget前后端配合来完成这个工作的,而且还有一些缺点(比如保存的ht ...
- 修改织梦默认提示"dedecms提示信息!"
在使用dedecms搜索的时候如果搜索频率过快,经常会跳出一个提示窗口提示"管理员设定搜索时间间隔为*秒,请稍后再试!".怎么自定义Dedecms提示信息呢?让心存不轨的家伙少一个 ...
- 机器学习公开课笔记(4):神经网络(Neural Network)——表示
动机(Motivation) 对于非线性分类问题,如果用多元线性回归进行分类,需要构造许多高次项,导致特征特多学习参数过多,从而复杂度太高. 神经网络(Neural Network) 一个简单的神经网 ...