Gym-270437A problem1

题目

https://vjudge.net/problem/Gym-270437A

题目大意

本题为一道模拟题,题目给定戊烷中的化学键,不同碳原子用1~6的数字来表示,要求判断这是哪一种戊烷。由于每种戊烷中有五个化学键,因此输入只给定输入组数,每次输出对应的英文名称。题目已经给出不同结构戊烷和其对应的名称,对应关系如图。
在这里插入图片描述

解题思路

本题较为简单,对于n-hexane和2,2-dimethylbutane这两种只需要判断其中连接化学键数目最多的碳原子连接了几个化学键即可,在输入时便可以做好对应的记录,二者分别对应1、4。2,3-dimethylbutane因为结构特殊,含有两个连接三条化学键的碳原子,也很好区分。至于剩下两种,结构比较相似,判断方法是观察与含三个化学键的碳原子所连接的三个碳原子包含的化学键数目。如图可知2-methylpentane连接了两个含一个化学键和一个含两个化学键的碳原子,3-methylpentane连接了两个含两个个化学键和一个含一个化学键的碳原子。在输入时只要记录每个编号的原子连接的对象,对于结构中只有一个连接了三个碳原子的结构,根据以上判别方法即可区分。

具体代码

#include <iostream> 
#include <cstdio> 
#include <fstream> 
#include <algorithm> 
#include <cmath> 
#include <deque> 
#include <vector> 
#include <queue> 
#include <string> 
#include <cstring> 
#include <map> 
#include <stack> 
#include <set> 
#include<cstdlib>
#include<ctime>
#include<iomanip>
#define ll long long
#define FOR(i,a,n) for(register int i=a;i<n;i++)
#define RF(i,a,n) for(register int i=a;i>n;i--)
#define NIL -1

using namespace std;

int num[10],ans[10];

int main()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		int a,b,flag = 0;
		vector<int> ss[10];
		memset(num,0,sizeof(num));
		memset(ans,0,sizeof(ans));
		for(int j = 1; j < 6; j++)
		{
			cin >> a >> b;
			num[a]++;
			num[b]++;
			ss[a].push_back(b);
			ss[b].push_back(a);
		}
		for(int j = 1; j < 7; j++)
		{
			if(num[j] == 3)
			{
				int aaa = 0;
				for(int k = 0; k < 3; k++)
				{
					if(num[ss[j][k]] == 1)
					{
						aaa++;
					}
				}
				if(aaa == 2)
				{
					flag = 1;
				}
			}
			ans[num[j]]++;
		}
		if(ans[2] == 4)
		{
			cout << "n-hexane" << endl;
		}
		else if(ans[3] == 2)
		{
			cout << "2,3-dimethylbutane" << endl;
		}
		else if(ans[4] == 1)
		{
			cout << "2,2-dimethylbutane" << endl;
		}
		else if(flag == 1)
		{
			cout << "2-methylpentane" << endl;
		}
		else
		{
			cout << "3-methylpentane" << endl;
		}
	}
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值