(code jam)Problem C. T9 Spelling

本文详细介绍了如何使用手机输入法将字母映射到按键组合,并解释了如何通过按键和空格符号来输入文本。重点在于理解同一按键两次输入之间的停顿表示,以及特殊字符的输入方式。

Problem

The Latin alphabet contains 26 characters and telephones only have ten digits on the keypad. We would like to make it easier to write a message to your friend using a sequence of keypresses to indicate the desired characters. The letters are mapped onto the digits as shown below. To insert the character B for instance, the program would press22. In order to insert two characters in sequence from the same key, the user must pause before pressing the key a second time. The space character ' ' should be printed to indicate a pause. For example, 2 2 indicates AA whereas 22 indicates B.

Input

The first line of input gives the number of cases, NN test cases follow. Each case is a line of text formatted as

desired_message

Each message will consist of only lowercase characters a-z and space characters ' '. Pressing zero emits a space.

Output

For each test case, output one line containing "Case #x: " followed by the message translated into the sequence of keypresses.

Limits

1 ≤ N ≤ 100.

Small dataset

1 ≤ length of message in characters ≤ 15.

Large dataset

1 ≤ length of message in characters ≤ 1000.

Sample


Input 

Output 
4
hi
yes
foo  bar
hello world

Case #1: 44 444
Case #2: 999337777
Case #3: 333666 6660 022 2777
Case #4: 4433555 555666096667775553

题意就是如题,应该不看都能看懂,就是平常手机输入法,注意空格用0输出,相同数字就用空格输出。

结果大数据纠结在上一次输入的也要记录!也就是说上一次输入比如是yes 后一次输入sk。那个s也继承上一次输入的s,要输出一个空格!!!坑啊。。。

#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;
int main()
{
	int t,i,j;
	char s[10100];
	freopen("C-large-practice.in","r",stdin);
	freopen("output.out","w",stdout);
	scanf("%d",&t);
	getchar();
	int qq=0;
	int k=0;
	while (t--)
	{
		printf("Case #%d: ",++qq);
		gets(s);
		int l=strlen(s);
		for (i=0;i<l;i++)
		{
			j=0;
			if (s[i]==' ') 
			{
				if (j==k) printf(" ");
				k=0;
				printf("0");
				continue;
			}
			j=s[i]-'a'+1;
			int y;
			if (j<=15)
			{
				y=(j-1)%3;
				j=ceil(j*1.0/3);
				j++;
			}
			else
			{
				if (j<=19) 
				{
					y=j-16;
					j=7;
					
				}
				else
				if (j<=22)
				{
					y=j-20;
					j=8;
					
				}
				else
				{
					y=j-23;
					j=9;
					
				}
			}
			if (j==k) printf(" ");
			k=j;
			for (int h=0;h<=y;h++)
				printf("%d",j);
		}
		printf("\n");
	}
	return 0;
}



内容概要:本文介绍了一个基于Matlab的综合能源系统优化调度仿真资源,重点实现了含光热电站、有机朗肯循环(ORC)和电含光热电站、有机有机朗肯循环、P2G的综合能源优化调度(Matlab代码实现)转气(P2G)技术的冷、热、电多能互补系统的优化调度模型。该模型充分考虑多种能源形式的协同转换与利用,通过Matlab代码构建系统架构、设定约束条件并求解优化目标,旨在提升综合能源系统的运行效率与经济性,同时兼顾灵活性供需不确定性下的储能优化配置问题。文中还提到了相关仿真技术支持,如YALMIP工具包的应用,适用于复杂能源系统的建模与求解。; 适合人群:具备一定Matlab编程基础和能源系统背景知识的科研人员、研究生及工程技术人员,尤其适合从事综合能源系统、可再生能源利用、电力系统优化等方向的研究者。; 使用场景及目标:①研究含光热、ORC和P2G的多能系统协调调度机制;②开展考虑不确定性的储能优化配置与经济调度仿真;③学习Matlab在能源系统优化中的建模与求解方法,复现高水平论文(如EI期刊)中的算法案例。; 阅读建议:建议读者结合文档提供的网盘资源,下载完整代码和案例文件,按照目录顺序逐步学习,重点关注模型构建逻辑、约束设置与求解器调用方式,并通过修改参数进行仿真实验,加深对综合能源系统优化调度的理解。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值