编程介的小学生 2017-04-17 06:11 采纳率: 20.3%
浏览 848
已采纳

Alkanes

The IUPAC nomenclature of organic chemistry is a systematic method of naming organic chemical compounds as recommended by the International Union of Pure and Applied Chemistry (IUPAC). Here are the rules for alkanes (except cyclic alkanes).

Straight-chain alkanes take the suffix "-ane" and are prefixed depending on the number of carbon atoms in the chain, following standard rules. The first few are:

Number of carbons 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
prefix meth eth prop but pent hex hept oct non dec undec dodec tridec tetradec pentadec
For example, the simplest alkane is CH4 methane, and the nine-carbon alkane CH3(CH2)7CH3 is named nonane.

Alkanes1
Branched alkanes are named as a straight-chain alkane with attached side chains (alkyl groups). Name each side chain by changing the suffix of the name of the alkane from "-ane" to "-yl". They are prefixed with a number indicating the carbon the group is attached to, counting from the end of the alkane chain. For example, (CH3)2CHCH3, is treated as a propane chain with a methyl group bonded to the middle (2) carbon, and given the systematic name 2-methylpropane.

If there is ambiguity in the position of the substituent, number the root chain so that sum of the numbers assigned to each side group will be as low as possible. For example, (CH3)2CHCH2CH3 is named 2-methylbutane, not 3-methylbutane.

Alkanes2
If there are multiple side-branches of the same size alkyl group, their positions are separated by commas in ascending order and the group prefixed with 'di'(2), 'tri'(3), 'tetra'(4), etc.(as for 5 ~ 15, you can refer to the table above and add 'a' at last, such as 'penta'(5), 'hexa'(6), etc), depending on the number of branches (e.g. C(CH3)4 2,2-dimethylpropane). If there are different groups, they are added in alphabetical order, separated by commas or hyphens: 3-ethyl-4-methylhexane. The longest possible main alkane chain is used; therefore 3-ethyl-4-methylhexane instead of 2,3-diethylpentane, even though these describe equivalent structures. The di-, tri- etc. prefixes are ignored for the purpose of alphabetical ordering of side chains (e.g. 3-ethyl-2,4-dimethylpentane, not 2,4-dimethyl-3-ethylpentane).

Input

There will be multiple cases.

For each cases, there are two numbers in the first line: n and m. n is the number of carbon atoms, and m is the number of carbon bond (witch is always equal to n-1).

There are m lines follow, indicating the identify numbers of two carbon atoms linked together. The identify numbers of the carbon atoms varies for 1 to n.

The main straight-chain of the alkane is no longer than 15, each side chain is no longer than 15, and the number of side chains with the same size is no larger than 15. Anyhow, the original IUPAC nomenclature is much more complicated, this problem states only a subset of the IUPAC nomenclature. You can assume all the test cases can be solved by the rules in the statement.

Output

Output the name of alkanes using IUPAC nomenclature.

Sample Input

5 4
1 2
2 3
2 5
2 4

4 3
1 2
2 3
3 4

13 12
1 2
2 3
3 4
4 5
5 6
6 7
7 8
9 10
10 11
11 12
12 13
12 4
Sample Output

2,2-dimethylpropane
butane
4-methyl-5-propylnonane

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-05-01 01:20
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 组策略中的计算机配置策略无法下发
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)