Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

大水题怎么没有人做

Posted by KatrineYang at 2016-11-15 12:58:06 on Problem 1524
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

int ctod(char c){
	switch(c){
		case 'V': return 0;
		case 'U': return 1;
		case 'C': return 2;
		case 'D': return 3;
		default: return -1;
	}
}

int stor(string s){
	int l = s.length();
	int res = 0;
	for(int i = 0; i < l; i++){
		res *= 4;
		res += ctod(s[i]);
	}
	return res;
}

int js(int r1, int r2, string op){
	switch(op[0]){
		case 'A': return r1+r2;
		case 'R': return r2/4;
		case 'L': return r2*4;
		default: return r2;
	}
}

int main(int argc, char **argv){
	
	cout << "COWCULATIONS OUTPUT" << endl;
	int n;
	cin >> n;
	while(n--){
		string s1, s2, op1, op2, op3, res;
		cin >> s1 >> s2 >> op1 >> op2 >> op3 >> res;
		int r1 = stor(s1), r2 = stor(s2);
		r2 = js(r1, js(r1, js(r1, r2, op1), op2), op3);
		if(r2 == stor(res)) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	cout << "END OF OUTPUT" << endl;	
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator