2020牛客暑期多校训练营(第九场)A.Groundhog and 2-Power Representation
2020牛客暑期多校训练营(第九场)A.Groundhog and 2-Power Representation
题目描述
Groundhog took a math class. In this class, his math teacher said:
Any positive integer can be represented by the power of . For example:.
And powers are expressed in parentheses.That is , stands for .Therefore, can be expressed as .
Further more,for is expressed with ,,137 can be finally expressed as .
Another example:.
Groundhog feels amazing and wants you to write a program to simulate the above content.You need to read in an expression that is a power of {2}2 and calculate its value.
输入描述:
Given a string, indicating the power representation.
输出描述:
Output the original number.
示例1
输入
2(2(2+2(0))+2)+2(2(2+2(0)))+2(2(2)+2(0))+2+2(0)
输出
1315
熟悉 的都知道 有个 函数可以直接求表达式的值,那么我们只需要把 替换成 即可,因为在 python 中 代表 幂,AC代码如下:
print(eval(input().replace('(','**(')))
本文地址:https://blog.csdn.net/qq_43765333/article/details/107884328
上一篇: Flask框架搭建2实现用户注册输入框
推荐阅读
-
2020牛客暑期多校训练营(第四场)——Basic Gcd Problem
-
2020牛客暑期多校训练营(第五场)
-
2020牛客暑期多校训练营(第九场) The Flee Plan of Groundhog
-
2020暑期牛客多校训练营第九场(K)The Flee Plan of Groundhog(lca,树形dp)
-
牛客多校第九场 Groundhog and 2-Power Representation(大整数,java)
-
2020牛客暑期多校训练营(第二场)Cover the Tree
-
2020牛客暑期多校训练营(第一场)H-Minimum-cost Flow
-
2020牛客暑期多校 第一场 F Infinite String Comparision(字符串)
-
Harmony Pairs 2020牛客暑期多校训练营(第六场)
-
2020牛客暑期多校训练营(第五场)解题报告DEFI