uestc 969 易位法字符串解密
2016-09-14 23:09
260 查看
题意:chinese
思路:就是按照题意模拟
题目链接:http://acm.uestc.edu.cn/#/problem/show/969
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cctype>
using namespace std;
const int maxn = 1005;
char a[30], s[1005], temp[1005];
int ran[30];
vector<node> v;
vector<char> v1;
struct node
{
char s[1005];
int val;
bool operator < (const node &rhs) const
{
return val < rhs.val;
}
};
int main()
{
int t;
scanf("%d", &t);
while (t--)
{
v.clear(), v1.clear();
scanf("%s%s", a, s);
int len1 = strlen(a), len2 = strlen(s);
int res = len2 / len1;
for (int i = 0; i < len1; i++)
{
ran[a[i] - 'A'] = i;
v1.push_back(a[i]);
}
sort(v1.begin(), v1.end());
node e;
for (int i = 0; i < len1; i++)
{
strncpy(e.s, s + i * res, res);
e.val = ran[v1[i] - 'A'];
v.push_back(e);
}
sort(v.begin(), v.end());
int cnt = 0;
while (cnt < res)
{
for (int i = 0; i < (int)v.size(); i++)
printf("%c", toupper(v[i].s[cnt]));
cnt++;
}
printf("\n");
}
return 0;
}
思路:就是按照题意模拟
题目链接:http://acm.uestc.edu.cn/#/problem/show/969
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cctype>
using namespace std;
const int maxn = 1005;
char a[30], s[1005], temp[1005];
int ran[30];
vector<node> v;
vector<char> v1;
struct node
{
char s[1005];
int val;
bool operator < (const node &rhs) const
{
return val < rhs.val;
}
};
int main()
{
int t;
scanf("%d", &t);
while (t--)
{
v.clear(), v1.clear();
scanf("%s%s", a, s);
int len1 = strlen(a), len2 = strlen(s);
int res = len2 / len1;
for (int i = 0; i < len1; i++)
{
ran[a[i] - 'A'] = i;
v1.push_back(a[i]);
}
sort(v1.begin(), v1.end());
node e;
for (int i = 0; i < len1; i++)
{
strncpy(e.s, s + i * res, res);
e.val = ran[v1[i] - 'A'];
v.push_back(e);
}
sort(v.begin(), v.end());
int cnt = 0;
while (cnt < res)
{
for (int i = 0; i < (int)v.size(); i++)
printf("%c", toupper(v[i].s[cnt]));
cnt++;
}
printf("\n");
}
return 0;
}
相关文章推荐
- PHP相关系列 - 兼容JAVA的PHP加密解密DES算法
- Java使用RSA加密解密签名及校验
- openssl 加密解密概念介绍
- C#的3DES加密/解密
- 加密 解密 签名 验签
- phpjm php加密的解密过程
- EBS加解密
- RSA不对称加密,公钥加密私钥解密,私钥加密公钥解密
- 使用Apache commons-codec Base64实现加解密(转)
- PHP和JS加解密算法代码 很有用
- 对称加密算法AES------使用AES算法对文件进行加密/解密的操作(JAVA)
- [置顶] 【CA】对于加密解密在系统中的应用的一些看法
- 六问解密慢公司:豆瓣到底是什么?(转 chinaz)
- Base64的加密与解密
- mysql 加密解密 AES_ENCRYPT AES_DECRYPT
- c# 加密解密示例
- js前端3des加密 后台java解密
- 使用密钥加密、解密实例
- vim复制粘贴解密(转)
- HTC ruu 解密 工具编译 提取解密key 自行解密 流程记录