1002.Phone Numbers

本文介绍了一种将电话号码转换为单词序列的方法,旨在通过将数字映射到字母来简化电话号码的记忆过程。文章提供了一个程序示例,用于寻找对应给定电话号码的最短单词序列。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

In the present world you frequently meet a lot of call numbers and they are going to be longer and longer. You need to remember such a kind of numbers. One method to do it in an easy way is to assign letters to digits as shown in the following picture:

1 ij    2 abc   3 def
4 gh    5 kl    6 mn
7 prs   8 tuv   9 wxy
        0 oqz
This way every word or a group of words can be assigned a unique number, so you can remember words instead of call numbers. It is evident that it has its own charm if it is possible to find some simple relationship between the word and the person itself. So you can learn that the call number 941837296 of a chess-playing friend of yours can be read as WHITEPAWN, and the call number 2855304 of your favourite teacher is read BULLDOG.
Write a program to find the shortest sequence of words (i.e. one having the smallest possible number of words) which corresponds to a given number and a given list of words. The correspondence is described by the picture above.

Input

Input contains a series of tests. The first line of each test contains the call number, the transcription of which you have to find. The number consists of at most 100 digits. The second line contains the total number of the words in the dictionary (maximum is 50 000). Each of the remaining lines contains one word, which consists of maximally 50 small letters of the English alphabet. The total size of the input doesn't exceed 300 KB. The last line contains call number −1.

Output

Each line of output contains the shortest sequence of words which has been found by your program. The words are separated by single spaces. If there is no solution to the input data, the line contains text “No solution.”. If there are more solutions having the minimum number of words, you can choose any single one of them.

Sample

inputoutput
7325189087
5
it
your
reality
real
our
4294967296
5
it
your
reality
real
our
-1
reality our
No solution.



//http://acm.timus.ru/print.aspx?space=1&num=1002


#include <iostream>
#include <string.h>
#include <vector>
using namespace std;


vector<string> outstr;
int Checkstr(){
    string phonenum ;
    cin>>phonenum;
    if(phonenum.size() == 2 and phonenum[0] == '-' and phonenum[1] == '1'){
        return  -1;
    }
    int count;
    cin>>count;
    vector <string> instr;
    vector <int> numstr;
    int sequence = 0;
    for(int i = 0 ; i < count ; i++){
        string tstr;
        cin>>tstr;
        instr.insert(instr.end(), tstr);
    }
    for(int i = 0 ; i < instr.size() ; i++){
        int tse = 0;
        for(int j = 0 ; j < instr[i].size() ; j++){
            int instrsq = -1;
            switch (instr[i][j]) {
                case 'i':;
                case 'j':
                    instrsq = 1;
                    break;
                case 'a':;
                case 'b':;
                case 'c':
                    instrsq = 2;
                    break;
                case 'd':;
                case 'e':;
                case 'f':
                    instrsq = 3;
                    break;
                case 'g':;
                case 'h':
                    instrsq = 4;
                    break;
                case 'k':;
                case 'l':
                    instrsq = 5;
                    break;
                case 'm':;
                case 'n':
                    instrsq = 6;
                    break;
                case 'p':;
                case 'r':;
                case 's':
                    instrsq = 7;
                    break;
                case 't':;
                case 'u':;
                case 'v':
                    instrsq = 8;
                    break;
                case 'w':;
                case 'x':;
                case 'y':
                    instrsq = 9;
                    break;
                case 'o':;
                case 'q':;
                case 'z':
                    instrsq = 0;
                    break;
                default:
                    break;
            }
            if(instrsq >=0 and (phonenum[sequence+j]-'0') == instrsq and tse != 1){
                tse = 0;
                cout<<"instr1 is "<<instr[i][j]<<endl;
            }else{
                cout<<"instr2 is "<<instr[i][j]<<endl;
                tse = 1;
                break;
            }
        }
        if(tse == 0){
            sequence = (int)instr[i].size() + sequence;
            outstr.insert(outstr.end(), instr[i]);
        }
    }
    return  0;
}


int main(int argc, const char * argv[]) {
    vector<string> ostr;
    while (1) {
        if(Checkstr() == -1){
            for(int i = 0 ; i < ostr.size() ; i++){
                cout<<ostr[i]<<endl;
            }
            break;
        }
        else{
            string stemp;
            if(outstr.size()<1){
                ostr.insert(ostr.end(), "No solution.");
            }
            else{
                for(int i = 0 ; i < outstr.size() ; i++){
                    stemp = stemp + outstr[i] + ' ';
                }
                ostr.insert(ostr.end(), stemp);
                outstr.clear();
                
            }
        }
    }
    return 0;
}


内容概要:本文详细介绍了扫描单分子定位显微镜(scanSMLM)技术及其在三维超分辨体积成像中的应用。scanSMLM通过电调透镜(ETL)实现快速轴向扫描,结合4f检测系统将不同焦平面的荧光信号聚焦到固定成像面,从而实现快速、大视场的三维超分辨成像。文章不仅涵盖了系统硬件的设计与实现,还提供了详细的软件代码实现,包括ETL控制、3D样本模拟、体积扫描、单分子定位、3D重建和分子聚类分析等功能。此外,文章还比较了循环扫描与常规扫描模式,展示了前者在光漂白效应上的优势,并通过荧光珠校准、肌动蛋白丝、线粒体网络和流感A病毒血凝素(HA)蛋白聚类的三维成像实验,验证了系统的性能和应用潜力。最后,文章深入探讨了HA蛋白聚类与病毒感染的关系,模拟了24小时内HA聚类的动态变化,提供了从分子到细胞尺度的多尺度分析能力。 适合人群:具备生物学、物理学或工程学背景,对超分辨显微成像技术感兴趣的科研人员,尤其是从事细胞生物学、病毒学或光学成像研究的科学家和技术人员。 使用场景及目标:①理解和掌握scanSMLM技术的工作原理及其在三维超分辨成像中的应用;②学习如何通过Python代码实现完整的scanSMLM系统,包括硬件控制、图像采集、3D重建和数据分析;③应用于单分子水平研究细胞内结构和动态过程,如病毒入侵机制、蛋白质聚类等。 其他说明:本文提供的代码不仅实现了scanSMLM系统的完整工作流程,还涵盖了多种超分辨成像技术的模拟和比较,如STED、GSDIM等。此外,文章还强调了系统在硬件改动小、成像速度快等方面的优势,为研究人员提供了从理论到实践的全面指导。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值