And Now, a Remainder from Our Sponsor

Problem Description
IBM has decided that all messages sent to and from teams competing in the ACM programming contest should be encoded. They have decided that instead of sending the letters of a message, they will transmit their remainders relative to some secret keys which are four, two-digit integers that are pairwise relatively prime. For example, consider the message "THE CAT IN THE HAT". The letters of this message are first converted into numeric equivalents, where A=01, B=02, ..., Z=26 and a blank=27. Each group of 3 letters is then combined to create a 6 digit number. (If the last group does not contain 3 letters it is padded on the right with blanks and then transformed into a 6 digit number.) For example
THE CAT IN THE HAT → 200805 270301 202709 142720 080527 080120
Each six-digit integer is then encoded by replacing it with the remainders modulo the secret keys as follows: Each remainder should be padded with leading 0’s, if necessary, to make it two digits long. After this, the remainders are concatenated together and then any leading 0’s are removed. For example, if the secret keys are 34, 81, 65, and 43, then the first integer 200805 would have remainders 1, 6, 20 and 38. Following the rules above, these combine to get the encoding 1062038. The entire sample message above would be encoded as
1062038 1043103 1473907 22794503 15135731 16114011

Input
The input consists of multiple test cases. The first line of input consists of a single positive integer n indicating the number of test cases. The next 2n lines of the input consist of the test cases. The first line of each test case contains a positive integer (< 50) giving the number of groups in the encoded message. The second line of each test case consists of the four keys followed by the encoded message.
Each message group is separated with a space.

Output
For each test case write the decoded message. You should not print any trailing blanks.

Sample Input
2
6
34 81 65 43 1062038 1043103 1473907 22794503 15135731 16114011
3
20 31 53 39 5184133 14080210 7090922

Sample Output
THE CAT IN THE HAT
THE END

2个回答

问题描述
IBM已经决定,所有发送到ACM编程竞赛的团队之间的消息都应该编码。他们已经决定不再发送信息的字母,而是相对于一些秘密密钥发送剩余的信息,这些秘密密钥是四位数整数,成对的相对素数。例如,考虑到“帽子里的猫”这句话。这条消息的字母首先转换为数字等价物,其中A=01,B=02,...,Z=26,a空白=27。每组3个字母然后组合,以创建一个6位数的数字。(如果最后一个组不包含3个字母,则在右边填充空格,然后转换成一个6位数字)。
戴帽子的猫
→200805 270301 202709 142720 080527 080120
然后将每个六位数整数替换为剩余的整数,然后按如下方式调制秘密键:如果有必要,每个余数都应加上前导0,使其长2位。在此之后,剩余的连接在一起,然后任何前导0被删除。例如,如果密钥是34、81、65和43,那么第一个整数200805将有剩余数1、6、20和38。按照上面的规则,这些组合得到编码1062038。上面的整个示例消息将被编码为
1062038 1043103 1473907 22794503 15135731 16114011
输入
输入由多个测试用例组成。第一行输入由一个正整数n组成,表示测试用例的数量。输入的下一个2n行由测试用例组成。每个测试用例的第一行包含一个正整数(<50),表示编码消息中的组数。每个测试用例的第二行由四个键组成,后面跟着编码的消息。
每个消息组都用一个空格分隔。
输出量
对于每个测试用例,编写解码消息。您不应打印任何尾随空白。
样本输入


34 81 65 43 1062038 1043103 1473907 22794503 15135731 16114011

20 31 53 39 5184133 14080210 7090922
样本输出
戴帽子的猫
终结

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
HDU1930 And Now, a Remainder from Our Sponsor
And Now, a Remainder from Our Sponsor Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 479 Accepted Submission(s): 195 Problem Description
#HDU1930#And Now, a Remainder from Our Sponsor(中国剩余定理)
And Now, a Remainder from Our Sponsor Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 950    Accepted Submission(s): 422 Problem Descripti
集训队专题(8)1004 And Now, a Remainder from Our Sponsor
And Now, a Remainder from Our Sponsor Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 669    Accepted Submission(s): 288 Problem Descr
【HDU】 1930 And Now, a Remainder from Our Sponsor
And Now, a Remainder from Our Sponsor题目链接 And Now, a Remainder from Our Sponsor 题目大意    现在有4个互相互素的数m1,m2,m3,m4。而且有一句话需要你用这4个数去加密。加密方法:     01代表A,02代表B,03代表C…..26代表Z,27代表空格,每三个数组成一个六位数(或是五位数),然后对这4个数分别
HDU1930 And Now, a Remainder from Our Sponsor 解线性同余方程的应用
这道题过的人很少,原因肯定是因为英语,这题目意思i 我看了好久,英语太差了,题目的意思是: 先给你四个数,然后给你n个数,把n个数中的每一个数给拆成四个数,怎么拆按题目要求,拆出来的这四个数作为同余方程   x≡ai(mod ri) 中的 ri,最先给出的四个作为key的四个数,作为方程中的 ai,然后求出x, 总的意思就是先给你四个作为key的四个数, 给你n个数,把n个数中的每一个
And Now, a Remainder from Our Sponsor (中国剩余定理互质情况)
And Now, a Remainder from Our Sponsor IBM has decided that all messages sent to and from teams competing in the ACM programming contest should be encoded. They have decided that instead of sending t...
【进制问题】【HDU2056】A + B Again
A + B Again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 15772    Accepted Submission(s): 6847 Problem Description There must be
Django DTL错误: Could not parse the remainder: '=='1'' from 'sort=='1''
设定模版中商品排行的分类:            &amp;lt;a href=&quot;/dailyfresh/list_{{typeinfo.id}}_1_1/&quot;                {%if sort== '1' %}                class=&quot;active&quot;                {%endif%}                &amp;gt;默认&amp;lt;/a&amp;gt;    ...
Django 出现:Could not parse the remainder: 'date::'Y /m /d''
在项目中练习中使用动态Url的时候在日期format的时候出现: Could not parse the remainder: ‘:date:’Y /m /d” from ‘post.date_time:date:’Y /m /d” 这里主要是自己跟着练习的时候出现疏忽了,原代码是:{% extends "base.html"%} {% block content %} <div class="
ACM-简单题之Ignatius and the Princess II——hdu1027
ACM 简单题 Ignatius and the Princess II hdu1027 康拓展开
在Django块标签中遇到的Error:Could not parse the remainder:'>' from 'user.age>'
在学习模板的块标签的使用的第一个例子中,就出现了这个错误。出错时的代码是这样写的: index.html<html lang="en"> <head> <meta charset="UTF-8"> <title>wuranghao</title> </head> <body> <h1>hello:{{user.name}}</h1> <h1>
【数论】 HDOJ 1930 && ZOJ 2945 And Now, a Remainder from Our Sponsor
中国剩余定理的简单应用。。。给你
hdu 1930 And Now, a Remainder from Our Sponsor 扩展欧几里得 解一元线性同余方程组
/** * url : http://acm.hdu.edu.cn/showproblem.php?pid=1930 * stratege : 解一元线性同余方程组, 扩展欧几里得 * Author: johnsondu * Status: johnsondu 0MS 284K 2207B C++ 2012-08-19 13:13:15 * Trick: There will be n
hdu1930 And Now, a Remainder from Our Sponsor-----中国剩余定理
And Now, a Remainder from Our Sponsor Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 380    Accepted Submission(s): 153 Problem Descrip
hdoj 2057 A+B again
A + B Again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 16854    Accepted Submission(s): 7255   Problem Description There must be many
A + B again (十六进制)
There must be many A + B problems in our HDOJ , now a new one is coming. Give you two hexadecimal integers , your task is to calculate the sum of them,and print it in hexadecimal too. Easy ? AC
[英语阅读]生而为赢—新东方英语背诵美文(29)-Gettysburg Address 在葛底斯堡的演说
Download  Fourscore and seven years ago, our fathers brought forth upon this continent a new Nation, conceived in Liberty, and dedicated to the
被小伙伴要出来的文章[0]:英语学习
开始前的话我真的忍不住吐槽csdn的文本编辑器,居然不会自动保存。写到两千多字windows更新重启,就没了···· 你们这是在加强我写代码不断ctrl+s的强迫症!!! 没想到在这儿第一篇正经文章是讲怎么学英语的。最近问我怎么学英语的人有点多,其实也就语音说个十多分钟的事情,不过太多次被问起来倒不如花几个小时写篇文章。这里我会大致谈谈对于英语的理解,推荐一些行之有效的方法。适合高中以上英语水平
940B. Our Tanya is Crying Out Loud(思维)
Right now she actually isn't. But she will be, if you don't solve this problem.You are given integers n, k, A and B. There is a number x, which is initially equal to n. You are allowed to perform two ...
HDU-1027 Ignatius and the Princess II
Now our hero finds the door to the BEelzebub feng5166. He opens the door and finds feng5166 is about to kill our pretty Princess. But now the BEelzebub has to beat our hero first. feng5166 says, “I ha...
OCP-1Z0-051 第73题 oracle内置函数
一、原题 Which tasks can be performed using SQL functions that are built into Oracle database ? (Choose three .) A. finding the remainder of a division. B. adding a number to a date for a resultant dat
项目管理之 Project Sponsor and Stakeholder
Project Sponsor &Stakeholder Stakeholder:包括这样的个人和组织,他们或者积极参与项目,或者其利益在项目执行中或者成功受到积极或消极影响。Stake”的直接翻译是“筹码”或“赌注”,所以“Stakeholder”可以直接翻译成为“拿着筹码的人”。但中文翻译为“项目干系人。任何项目经理在学习项目管理知识的过程中都明白“Project Sponsor ”(翻译
Monkey Party hdu 3506
题目类型:动态规划,属于区间性质的,可以利用四边形不等式加速。 题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=3506 题目大意:一群猴子围成圈,每个猴子互相不认识,猴王要给大家互相认识,每个猴子认识别人需要一个时间花费,而且A
sendemail好东西
参考 https://github.com/mogaal/sendemail/blob/master/sendEmail 代码#!/usr/bin/perl -w ############################################################################## ## sendEmail ## Written by: Brandon Zeh
阿里云 putty链接服务器出现 server refused our key
今天剁手阿里云,创建了密钥对绑定实例,puttygen生成ppk,putty配置参数,连接,一步一步来的,结果出现server refused out key,后来重启了一下实例,就成功了。也是无语。...
Nordic Collegiate Programming Contest (NCPC) 2017 C 在线查询,更新
One hundred years from now, in 2117, the International Collegiate Programming Contest (of which the NCPC is a part) has expanded significantly and it is now the Galactic Collegiate Programming Contest...
zoj 1256 What Day Is It?
What Day Is It? Time Limit: 2 Seconds      Memory Limit: 65536 KB The calendar now in use evolved from the Romans. Julius Caesar codified a calendar system that came to be known as the Ju
hdoj A + B Again
A + B Again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 16231    Accepted Submission(s): 7010 Problem Description There must be man
迁移到Android Studio 3.0
前言Google 发布了Android Studio 3.0,有很多功能值得我们使用,比如:Android Profiler, Android Plugin for Gradle 3.0.0(com.android.tools.build:gradle:3.0.0-alpha3)等。 今天这篇主要介绍下Android Plugin for Gradle 3.0.0.1.更新配置Gradle需要更新
F自己安装CocoaPods流程
Last login: Mon Oct 10 10:07:45 on ttys000 LdeiMac:~ L$ gem sources -l *** CURRENT SOURCES *** https://ruby.taobao.org/ https://gems.ruby-china.org/ LdeiMac:~ L$ sudo gem install
ACM-贪心策略
有如下规则: 1、 2、 3、
杭电ACM HDU 1031 Design T-Shirt
Design T-Shirt Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3331    Accepted Submission(s): 1641 Problem Description Soon after he d
每日英语好文翻译2
「We will not go quietly into the night! We will not vanish without a fight!」   Good morning. Good morning.  早上好!   In less than an hour, aircraft from here will join others from around the world, and y
What Day Is It?(模拟)
The calendar now in use evolved from the Romans. Julius Caesar codified a calendar system that came to be known as the Julian calendar. In this system, all months have 31 days, except for April, Jun
【 HDU 1853】Cyclic Tour 【MCMF or KM 解哈密顿环】
There are N cities in our country, and M one-way roads connecting them. Now Little Tom wants to make several cyclic tours, which satisfy that, each cycle contain at least two cities, and each city belo
Ebola Virus Fact Sheet
We need to know more about Ebola. It is now in Africa, but we need to raise our awareness! Document from CDC.
HDU 3506 Monkey Party
Far away from our world, there is a banana forest. And many lovely monkeys live there. One day, SDH(Song Da Hou), who is the king of banana forest, decides to hold a big party to celebrate Crazy Banan
Modulo and Reminder
数学与编程——求余、取模运算及其性质  标签: 求余取模可移植性 2015-01-18 12:19 276人阅读 评论(0) 收藏 举报 版权声明:本文为博主原创文章,未经博主允许不得转载。 一、求余运算(Remainder) (参考维基百科: http://zh.wikipedia.org/wiki/余数  http://en.wikipedia.o
杭电OJ--1027 Ignatius and the Princess II
Ignatius and the Princess II Problem Description Now our hero finds the door to the BEelzebub feng5166. He opens the door and finds feng5166 is about to kill our pretty Princess. But now the B
Codeforces544D:Destroying Roads(最短路)
In some country there are exactly n cities and m bidirectional roads connecting the cities. Cities are numbered with integers from 1 to n. If cities a and b are connected by a road, then in an h
相关热词 c# 增加元素 c#控制台简单加法 c# 服务端框架 c# 判断事件是否注册 c#中is和has c# udp 连接超时 c#词典 c#实现排列组合 c# oss 上传 c#判断输入的是否为ip