UVA 712 S-tree_uva

Source: Internet
Author: User

Summing up the topic of the law, if the input is x1,x2,x3, then X1 corresponding weights for the 4,x2 corresponding weights for the 2,x3 corresponding weights are 1, the other input and so on, are based on 2 values. For subsequent input to be judged, the corresponding values are computed, which is the position in the array, locating the element by position and outputting the line. The specific implementation see source code:

#include <iostream> #include <vector> #include <string> #include <set> #include <stack> # include<queue> #include <map> #include <algorithm> #include <cmath> #include <iomanip> #

include<cstring> #include <sstream> #include <cstdio> using namespace std;

int n;
	int main () {int amount = 0;
		while (CIN >> N) {amount++;
		if (n = = 0) break;
		Vector<int> order;
			for (int i = 0; i < n; i++) {string S;
			Cin >> S;
			int index = 0;
			for (int j = 1; J < S.size (); j + +) {index = index * + (s[j]-' 0 ');
		} order.push_back (index);
		} string data;
		CIN >> data;
		int m;
		Cin >> m;
		vector<char> result;
			for (int i = 0; i < m; i++) {string D;
			Cin >> D;
			int index = 0;
			for (int j = 0; J < Order.size (); j + +) {index = index * 2 + (d[order[j]-1]-' 0 ');
		} result.push_back (Data[index]); } cout << "S-tree #" <<amount<< ": "<< Endl;
		for (int i = 0; i < result.size (); i++) cout << result[i];
	cout << Endl << Endl;
return 0; }



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.