A - 译码 - 中南林业科技大学第十一届程序设计大赛

链接:https://www.nowcoder.com/acm/contest/124/A
来源:牛客网

题目描述
现在定义一种编码规则:对于长度为3的字符串(均由小写字母组成),首先按照字典序进行排序,即aaa,aab,aac,…,zzz,
将这些字符串按照顺序依次从00001至17575编码(前缀0不可省略),即aaa=00000,aab=00001,aac=00002,…,zzz=17575。
现在给出一串数字,请你通过计算输出这串数字对应的原字符串。(输入保证该数字长度为5的倍数)

例如输入000021757511222,每五位编号对应于一个字符串
编号00002对应字符串 aac
编号17575对应字符串 zzz
编号11222对应字符串 qpq

故输出为 aaczzzqpq
输入描述:
输入第一行包含一个整数T,代表测试案例个数。(0 < T ≤10)

接下来每个测试案例包括两行,第一行为一个整数length(0

#include<cstdio>
#include<algorithm>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;

int main()
{
    int t;
    scanf("%d", &t);
    while (t--)
    {
        int len;
        scanf("%d", &len);
        int a[100];
        for (int i = 0; i < len/5; i++)
        {
            scanf("%5d", &a[i]);
            int x, y, z;
            z = a[i] % 26;
            a[i] /= 26;
            y = a[i] % 26;
            a[i] /= 26;
            x = a[i];
            printf("%c%c%c", x + 'a', y + 'a', z + 'a');
        }
        printf("\n");
    }
}

猜你喜欢

转载自blog.csdn.net/q435201823/article/details/80384558
今日推荐