UVA458(ASCII应用+找规律)
2014-11-30 12:49
134 查看
The Decoder
Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %llu
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18811
Description
Write a complete program that will correctly decode a set of characters into a valid message. Your program should read a given file of a simple coded set of characters and print the exact message that the characters contain. The code key for this simple coding
is a one for one character substitution based upon a single arithmetic manipulation of the printable portion of the ASCII character set.
Input and Output
For example: with the input file that contains:
1JKJ'pz'{ol'{yhklthyr'vm'{ol'Jvu{yvs'Kh{h'Jvywvyh{pvu5
1PIT'pz'h'{yhklthyr'vm'{ol'Pu{lyuh{pvuhs'I|zpulzz'Thjopul'Jvywvyh{pvu5
1KLJ'pz'{ol'{yhklthyr'vm'{ol'Kpnp{hs'Lx|pwtlu{'Jvywvyh{pvu5
your program should print the message:
*CDC is the trademark of the Control Data Corporation.
*IBM is a trademark of the International Business Machine Corporation.
*DEC is the trademark of the Digital Equipment Corporation.
Your program should accept all sets of characters that use the same encoding scheme and should print the actual message of each set of characters.
Sample Input
1JKJ'pz'{ol'{yhklthyr'vm'{ol'Jvu{yvs'Kh{h'Jvywvyh{pvu5
1PIT'pz'h'{yhklthyr'vm'{ol'Pu{lyuh{pvuhs'I|zpulzz'Thjopul'Jvywvyh{pvu5
1KLJ'pz'{ol'{yhklthyr'vm'{ol'Kpnp{hs'Lx|pwtlu{'Jvywvyh{pvu5
Sample Output
*CDC is the trademark of the Control Data Corporation.
*IBM is a trademark of the International Business Machine Corporation.
*DEC is the trademark of the Digital Equipment Corporation.
解题思路:
找下规律就能发现最后输出的每个字符是原来字符的ASCII码值-7后的字符。
完整代码:
Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %llu
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18811
Description
Write a complete program that will correctly decode a set of characters into a valid message. Your program should read a given file of a simple coded set of characters and print the exact message that the characters contain. The code key for this simple coding
is a one for one character substitution based upon a single arithmetic manipulation of the printable portion of the ASCII character set.
Input and Output
For example: with the input file that contains:
1JKJ'pz'{ol'{yhklthyr'vm'{ol'Jvu{yvs'Kh{h'Jvywvyh{pvu5
1PIT'pz'h'{yhklthyr'vm'{ol'Pu{lyuh{pvuhs'I|zpulzz'Thjopul'Jvywvyh{pvu5
1KLJ'pz'{ol'{yhklthyr'vm'{ol'Kpnp{hs'Lx|pwtlu{'Jvywvyh{pvu5
your program should print the message:
*CDC is the trademark of the Control Data Corporation.
*IBM is a trademark of the International Business Machine Corporation.
*DEC is the trademark of the Digital Equipment Corporation.
Your program should accept all sets of characters that use the same encoding scheme and should print the actual message of each set of characters.
Sample Input
1JKJ'pz'{ol'{yhklthyr'vm'{ol'Jvu{yvs'Kh{h'Jvywvyh{pvu5
1PIT'pz'h'{yhklthyr'vm'{ol'Pu{lyuh{pvuhs'I|zpulzz'Thjopul'Jvywvyh{pvu5
1KLJ'pz'{ol'{yhklthyr'vm'{ol'Kpnp{hs'Lx|pwtlu{'Jvywvyh{pvu5
Sample Output
*CDC is the trademark of the Control Data Corporation.
*IBM is a trademark of the International Business Machine Corporation.
*DEC is the trademark of the Digital Equipment Corporation.
解题思路:
找下规律就能发现最后输出的每个字符是原来字符的ASCII码值-7后的字符。
完整代码:
#include <functional> #include <algorithm> #include <iostream> #include <fstream> #include <sstream> #include <iomanip> #include <numeric> #include <cstring> #include <climits> #include <cassert> #include <complex> #include <cstdio> #include <string> #include <vector> #include <bitset> #include <queue> #include <stack> #include <cmath> #include <ctime> #include <list> #include <set> #include <map> using namespace std; #pragma comment(linker, "/STACK:102400000,102400000") typedef long long LL; typedef double DB; typedef unsigned uint; typedef unsigned long long uLL; /** Constant List .. **/ //{ const int MOD = int(1e9)+7; const int INF = 0x3f3f3f3f; const LL INFF = 0x3f3f3f3f3f3f3f3fLL; const DB EPS = 1e-9; const DB OO = 1e20; const DB PI = acos(-1.0); //M_PI; string s; int main() { #ifdef DoubleQ freopen("in.txt","r",stdin); #endif while(getline(cin , s)) { int len = s.length(); for(int i = 0 ; i < len ; i ++) { s[i] = (char)(s[i] - 7); } cout << s << endl; } }
相关文章推荐
- UVa OJ 458-The Decoder
- UVA 458 The Decoder
- UVa 458 - The Decoder
- Volume 0. Getting Started Uva10055, 10071,10300,458,494,490,414,445,488,489,694,457
- UVa458 - The Decoder-字符串-难度1
- uva 458
- UVA 458 - The Decoder
- UVA - 458 - The Decoder
- Uva 458 - The Decoder
- [解题报告]《算法竞赛入门经典》基础题Volume 0. Getting Started Uva10055 Uva10071 Uva10300 Uva458 Uva494 Uva490 Uva445 Uva488 Uva489 Uva694 Uva457
- UVA 458 The Decoder
- UVA 458(The Decoder)
- UVa 458 - The Decoder
- UVa 458 - The Decoder
- UVA458 The Decoder【编码】
- UVA 458
- UVA 458 - The Decoder
- uva 458 - The Decoder
- UVA 458-The Decoder
- UVa 458 The Decoder (最简代码!)