浙江财经大学
信工学院ACM集训队

Codeforces Beta Round #76 (Div. 2 Only) A. Restoring Password

本文由 Ocrosoft 于 2016-10-29 16:28:07 发表

Igor K. always used to trust his favorite Kashpirovsky Antivirus. That is why he didn’t hesitate to download the link one of his groupmates sent him via QIP Infinium. The link was said to contain “some real funny stuff about swine influenza”. The antivirus had no objections and Igor K. run the flash application he had downloaded. Immediately his QIP Infinium said: “invalid login/password”.

Igor K. entered the ISQ from his additional account and looked at the info of his main one. His name and surname changed to “H1N1” and “Infected” correspondingly, and the “Additional Information” field contained a strange-looking binary code 80 characters in length, consisting of zeroes and ones. “I’ve been hacked” — thought Igor K. and run the Internet Exploiter browser to quickly type his favourite search engine’s address.

Soon he learned that it really was a virus that changed ISQ users’ passwords. Fortunately, he soon found out that the binary code was actually the encrypted password where each group of 10 characters stood for one decimal digit. Accordingly, the original password consisted of 8 decimal digits.

Help Igor K. restore his ISQ account by the encrypted password and encryption specification.

Input

The input data contains 11 lines. The first line represents the binary code 80 characters in length. That is the code written in Igor K.’s ISQ account’s info. Next 10 lines contain pairwise distinct binary codes 10 characters in length, corresponding to numbers 0, 1, …, 9.

Output

Print one line containing 8 characters — The password to Igor K.’s ISQ account. It is guaranteed that the solution exists.

Examples
input
01001100100101100000010110001001011001000101100110010110100001011010100101101100
0100110000
0100110010
0101100000
0101100010
0101100100
0101100110
0101101000
0101101010
0101101100
0101101110

output
12345678

input
10101101111001000010100100011010101101110010110111011000100011011110010110001000
1001000010
1101111001
1001000110
1010110111
0010110111
1101001101
1011000001
1110010101
1011011000
0110001000

output
30234919

Solution

题意:上面一串80字符的是密文,下面的10个是0-9的字典,把80的字符串切成8份,10个字符一份,跟下面的字典匹配。

#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <ctime>
#include <string>
#include <cstdio>
#include <vector>
#include <cctype>
#include <climits>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
#define strend string::npos
#define ms(a) memset(a,0,sizeof(a))
typedef long long LL;
const LL LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const int MAXN = 100000 + 10;
const int MOD = 1000000009;
int gcd(int a, int b)
{
	if (!b)return a;
	return gcd(b, a%b);
}
using namespace std;
//or2..or2..or2..or2..//
int main()
{
	string s; cin >> s;
	string v[20];
	for (int i = 0; i < 10; i++)cin >> v[i];
	string::iterator it = s.begin();
	string t = "";
	for (; it != s.end(); it++)
	{
		t.push_back(*it);
		if (t.size() == 10)
		{
			for (int j = 0; j < 10; j++)
				if (!t.compare(v[j])) { printf("%d", j); break; }
			t.clear();
		}
	}
	cout << endl;
	return 0;
}

欢迎转载,请保留出处与链接。Ocrosoft » Codeforces Beta Round #76 (Div. 2 Only) A. Restoring Password

点赞 (0)or拍砖 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址