CCF——2019/12/15——第三题——化学方程式(30分)

/*30分....*/

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>


using namespace std;

const int M = 53;
int a[M];//等号前面的各元素个数 
int b[M];//等号后面的各元素个数 

int f(char x){
	if(x=='A') {return 0;} if(x=='H') {return 7;} if(x=='O') {return 14;} if(x=='U') {return 20;} 
	if(x=='B') {return 1;} if(x=='I') {return 8;} if(x=='P') {return 15;} if(x=='V') {return 21;} 
	if(x=='C') {return 2;} if(x=='J') {return 9;} if(x=='Q') {return 16;} if(x=='W') {return 22;} 
	if(x=='D') {return 3;} if(x=='K') {return 10;} if(x=='R') {return 17;} if(x=='X') {return 23;} 
	if(x=='E') {return 4;} if(x=='L') {return 11;} if(x=='S') {return 18;} if(x=='Y') {return 24;}
	if(x=='F') {return 5;} if(x=='M') {return 12;} if(x=='T') {return 19;} if(x=='Z') {return 25;} 
	if(x=='G') {return 6;} if(x=='N') {return 13;}
	
	if(x=='a') {return 26;} if(x=='h') {return 33;} if(x=='o') {return 40;} if(x=='u') {return 46;} 
	if(x=='b') {return 27;} if(x=='i') {return 34;} if(x=='p') {return 41;} if(x=='v') {return 47;} 
	if(x=='c') {return 28;} if(x=='j') {return 35;} if(x=='q') {return 42;} if(x=='w') {return 48;} 
	if(x=='d') {return 29;} if(x=='k') {return 36;} if(x=='r') {return 43;} if(x=='x') {return 49;} 
	if(x=='e') {return 30;} if(x=='l') {return 37;} if(x=='s') {return 44;} if(x=='y') {return 50;}
	if(x=='f') {return 31;} if(x=='m') {return 38;} if(x=='t') {return 45;} if(x=='z') {return 51;} 
	if(x=='g') {return 32;} if(x=='n') {return 39;}
	
}

int main(void)
{
	int n;
	cin >> n;	
	string s;
	
	for(int k=0; k<n; k++){
		
		memset(a,0,sizeof(a));
		memset(b,0,sizeof(b));
		s.clear();
		
		
		cin >> s;
		int ss = 0;
		for(int i=0; s[i] != '='; i++){//等号之前
			if(s[i] != '+'){
				a[f(s[i])]++ ;
			}
			ss++;	
		}
		for(int i=ss+1; i<s.length(); i++){
			if(s[i] != '+'){
				b[f(s[i])]++;
			}
		}
		
		int flag = 0;
		for(int i=0; i<M; i++){
			if(a[i] != b[i]){
				flag = 1;
			}
			
			//cout << a[i] << "vs" << b[i] << " __  ";
		}
		
		if(flag == 0){
			cout << "Y" << endl;
		}else if(flag == 1){
			cout << "N" << endl;
		}
			
	}
	
	return 0;
}

30分 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值