fzu——Problem 2034 Password table
2013-11-11 11:14
330 查看
Description
Do you know password table? A password table is used to protect the security of the online account. When a user needs to login to his/her online account or pay for money, he/she may need to fill in the password according to his/her own password table. For example,
if one user has the following table and the online system requires him/her to input the password of “A4B7D1”, he/she may input “577000”.
Input
The first line of the input contains an integer T(T≤100), indicating the number of test cases. The first line of each case contains three numbers n(5≤n≤9), m(5≤m≤9) and q(1≤q≤100) representing the length and width of the password table, and the total number
of queries (Look at the password table above, its length is 8 and its width is 5). Each of the following n lines contains m numbers, representing the given password table.
Then, each of the following q lines represents a query with the format of "L1D1L2D2L3D3" (L1, L2 and L3 are letters. D1, D2 and D3 are digits), just like the example in paragraph one.
Output
For each test case, print a line containing the test case number (beginning with 1). For each query in one test case, please output its corresponding password in one line.
Sample Input
1
8 5 2
94 62 80 00 24
79 11 07 80 03
32 66 12 89 48
57 82 36 69 32
54 66 91 54 93
12 14 37 92 83
52 70 33 89 95
59 91 01 80 69
A4B7D1
E5C3B2
Sample Output
Case 1:
577000
931211
网上找的:
自己写的(已改正):
Do you know password table? A password table is used to protect the security of the online account. When a user needs to login to his/her online account or pay for money, he/she may need to fill in the password according to his/her own password table. For example,
if one user has the following table and the online system requires him/her to input the password of “A4B7D1”, he/she may input “577000”.
Input
The first line of the input contains an integer T(T≤100), indicating the number of test cases. The first line of each case contains three numbers n(5≤n≤9), m(5≤m≤9) and q(1≤q≤100) representing the length and width of the password table, and the total number
of queries (Look at the password table above, its length is 8 and its width is 5). Each of the following n lines contains m numbers, representing the given password table.
Then, each of the following q lines represents a query with the format of "L1D1L2D2L3D3" (L1, L2 and L3 are letters. D1, D2 and D3 are digits), just like the example in paragraph one.
Output
For each test case, print a line containing the test case number (beginning with 1). For each query in one test case, please output its corresponding password in one line.
Sample Input
1
8 5 2
94 62 80 00 24
79 11 07 80 03
32 66 12 89 48
57 82 36 69 32
54 66 91 54 93
12 14 37 92 83
52 70 33 89 95
59 91 01 80 69
A4B7D1
E5C3B2
Sample Output
Case 1:
577000
931211
网上找的:
#include<iostream> #include<cstdio> #include<algorithm> #include<cstring> using namespace std; #define N 10 int T; int n , m , q; int G ; char str ; int main(){ scanf("%d" , &T); int t = 1; while(T--){ printf("Case %d:\n" , t++); scanf("%d%d%d" , &n , &m , &q); for(int i = 1 ; i <= n ; i++){ for(int j = 1 ; j <= m ; j++) scanf("%d" , &G[i][j]); } for(int i = 0 ; i < q ; i++){ scanf("%s" , str); printf("%02d" , G[str[1]-'0'][str[0]-'A'+1]); printf("%02d" , G[str[3]-'0'][str[2]-'A'+1]); printf("%02d\n" , G[str[5]-'0'][str[4]-'A'+1]); } } return 0; }
自己写的(已改正):
#include <iostream> #include <stdio.h> #include <cstring> using namespace std; int main() { int t; cin>>t; int n,m,q; int a[20][20]; int a1[200][20]; char str[20]; int d=0; for(int k=1;k<=t;k++) { cin>>n>>m>>q; memset(a1,0,sizeof(a1)); memset(a,0,sizeof(a)); for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { cin>>a[i][j]; } } for(int i=0;i<q;i++) { scanf("%s",str); a1[i][0]=a[str[1]-'0'][str[0]-'A'+1]; a1[i][1]=a[str[3]-'0'][str[2]-'A'+1]; a1[i][2]=a[str[5]-'0'][str[4]-'A'+1]; } cout<<"Case "<<k<<":"<<endl; for(int i=0;i<q;i++) { for(int j=0;j<3;j++) { printf("%02d",a1[i][j]); } cout<<endl; } } return 0; } /* 8 5 2 94 62 80 00 24 79 11 07 80 03 32 66 12 89 48 100 82 36 69 32 54 66 91 54 93 12 14 37 92 83 52 70 33 89 95 59 91 01 80 69 A4B7D1 E5C3B2 */
相关文章推荐
- FZU Problem 2034 Password table (简单模拟题)
- FZU 2034-Password table(模拟)
- fzu 2034 Password table(水题)
- FZU 2034 Password table(水题)
- FZU 2011年全国大学生程序设计邀请赛(福州) 2034 Password table
- FZU 2034 Password table
- fzu 2034 Password table (水)
- Problem 1202 信与信封问题 from http://acm.fzu.edu.cn/problem.php?pid=1202
- FZU 2271:Problem 2271 X <Floyd>
- fzu Problem 2125 简单的等式
- FZU Problem 2062 Suneast & Yayamao
- Maximum Value Problem FZU - 2037
- FZU Problem 2146 Easy Game ( 数学啊)
- FZU Problem 1491 机器人测试(BFS)
- fzu——Problem 2091 播放器
- fzu Problem 2139 久违的月赛之二
- FZU-Problem 2150 Fire Game
- FZU A-B problem
- Problem 1046 Tempter of the Bone, from http://acm.fzu.edu.cn/problem.php?pid=1046
- FZU 2215 Simple Polynomial Problem (多项式乘法 栈)