python 编码问题

Question:

题:

A power function is that positive number that can be expressed as x^x i.e x raises to the power of x, where x is any positive number. You will be given an integer array A and you need to print if the elements of array A are Power Number or not.

一种功率函数是可以表示为x ^ X,X加注到x的功率即正数,其中x是任意正数。 您将得到一个整数数组A,并且如果数组A的元素是否为Power Number,则需要打印。

Input:

输入:

The first line contains N, a positive integer. The next line contains N spaces – separated integers.

第一行包含N ,一个正整数。 下一行包含N个空格-分隔的整数。

    3
1 3 4

Output:

输出:

For every integer print "Yes" if it’s a power number else print "No". these outputs must be separated by spaces.

对于每个整数,如果是幂数,则打印“ Yes” ,否则打印“ No” 。 这些输出必须用空格分隔。

    Yes  No  Yes

Constraints:

限制条件:

    1 <= N  <= 100
1 <= A[i] <= 10^16

Explanation/Solution:

说明/解决方案:

In this question, we have to check that the given numbers in an array are power numbers or not. We will find it with the help of a power function in python. So we can do this by comparing each element with the power number so first we take input from the user and create the array of size N. then make another array that stores the power number from 1 to 14. The key focus of this question is on constraints. In this question, the constraints are given till 10^16 numbers.

在这个问题中,我们必须检查数组中给定的数字是否为幂数。 我们将在python中的幂函数的帮助下找到它。 因此,我们可以通过将每个元素与幂数进行比较来做到这一点,因此首先我们从用户那里获取输入并创建大小为N的数组。 然后制作另一个存储从1到14的幂数的数组。这个问题的重点是约束。 在这个问题中,给出的约束直到10 ^ 16个数字。

To solve this question, we are using Python3.

为了解决这个问题,我们使用Python3。

Code:

码:

# input N
N = int(input())
# input N array elements
Arr = list(map(int, input().split()))
# create another blank/empty array
Brr = []
for i in range(15):
# Append the power numbers in blank  array
Brr.append(pow(i, i))
for i in range(N):
# compare the give array with
# power number array  one by one
if(Arr[i]  in  Brr):
# if it matches print Yes other wise NO
print('Yes', end=' ')
else:
print('No', end=' ')

Output

输出量

RUN 1:
5
1 4 3 16 256
Yes Yes No No Yes
RUN 2:
5
2 4 8 16 32
No Yes No No No

翻译自: https://www.includehelp.com/python/power-challenge-competitive-coding-questions.aspx

python 编码问题

python 编码问题_Python电源挑战| 竞争编码问题相关推荐

  1. python可以处理任何字符编码文本_python数据类型、字符编码、文件处理

    介绍: 1.什么是数据? 例:x=10,10是我们要存储的数据 2.为何数据要分不同的类型? 数据是用来表示状态的,不同的状态用不同的类型的数据去表示 1.数据类型 1.数字(整形,长整形,浮点型,复 ...

  2. python文本编码转换_python实现文件批量编码转换及注意事项

    起因:大三做日本交换生期间在修一门C语言图像处理的编程课,在配套书籍的网站上下载了sample,但是由于我用的ubuntu18.04系统默认用utf-8编码,而文件源码是Shift_JIS编码,因而文 ...

  3. python声明编码作用_Python源代码中的编码声明字符串的作用

    原来以为Python编源代码头部的#encoding: utf8的字符串对于python的实际编码解析是没有影响的. 但是今天发现一个很好玩的问题.Mark一下. 当python的代码中存在类似u'中 ...

  4. python网址编码转换_python字符串与url编码的转换实例

    python字符串与url编码的转换实例 更新时间:2018年05月10日 10:27:46 作者:Tangzongyu123 今天小编就为大家分享一篇python字符串与url编码的转换实例,具有很 ...

  5. python编码示例_python urllib中的编码处理示例

    复制代码 代码如下: >>> import urllib >>> data = '丽江' >>> print data 丽江 >>&g ...

  6. python字符编码讲解_python 字符编码讲解

    ASCII控制字符  Unicode编码 ASCII(American Standard Code for Information Interchange,美国信息互换标准代码,ASCⅡ)是基于拉丁字 ...

  7. python 字符串 编码 解码_Python 字符串编解码研究

    Python 2.X 在输入汉字和特殊字符的时候,经常遇到编码解码的问题,究其原因,编译器默认将文件当做ascii编码,因此要正确的实现编解码的转换,需要进行一些设置. 首先让我们来了解几个概念. 文 ...

  8. python中文编码正则_python的unicode编码问题(以正则表达式为例)

    unicode是python的内部编码. 字符串在Python内部的表示是unicode编码,因此,在做编码转换时,通常需要以unicode作为中间编码,即先将其他编码的字符串解码(decode)成u ...

  9. python采用哪种编码方式_Python编码格式的指定方式

    参考自: http://python.jobbole.com/85852/, 原文探究的更深,有兴趣的可以去看看. 简介来讲就是使用一种特殊的注释来声明编码格式,如何判断这种格式也用了很简单粗暴有效的 ...

最新文章

  1. cisco交换机Telnet配置
  2. wxWidgets:你好,世界
  3. Server Tomcat v8.0 Server at localhost was unable to start within 45 seconds. 报错详细
  4. python调用c的配置文件_python调用c
  5. Jdbc连接mysql的五种连接方式
  6. lua安全之关于lua扩展第三方库
  7. 淘宝生成器在线制作,淘宝全屏代码装修店招导航教程
  8. 通俗理解博弈论相关术语
  9. 4级网络工程师第5套知识点
  10. 2021年危险化学品经营单位安全管理人员考试报名及危险化学品经营单位安全管理人员作业考试题库
  11. c语言memcmp函数详解,C语言之memcmp()函数
  12. 贪心算法_排队不等式_绝对值不等式_推公式
  13. 如何正确开展网络口碑营销?
  14. 2011年成都信息工程学院第二季极客大挑战逆向第二题Crackwho破文
  15. 灵魂三问:什么是接口测试,接口测试怎么玩,接口自动化测试怎么玩?
  16. 代理游戏平台怎么挣钱?
  17. 编辑距离WER/CER计算的一种python实现
  18. 推荐几个容易中的计算机EI源刊(转)
  19. 利用traffic control模拟网络延迟和丢包
  20. 微信小程序常识——只需4个文件即可构成一个完整的微信小程序项目

热门文章

  1. 基于matlab的ldpc编码的构造,基于LDPC编码的GMSK调制与解调及matlab仿真实现(含录像)...
  2. excel表格从某个标志计算机,让Excel也玩多标签 多个图表一个窗口 -电脑资料
  3. oracle插补缺失日期,Oracle连接 ORA-28001: 口令已经失效解决方法
  4. 已知a类被打包在packagea_2021考研干货:199管理类联考综合逻辑归纳习题(1)
  5. HTML下拉菜单怎么做成横向,css导航条横向带下拉菜单
  6. 程序员绩效总结_年终总结怎么写?
  7. C#统计字符出现的个数【C#】
  8. Milking Time【动态规划-dp】
  9. 在HubSpot是如何应对Fat JAR困境的
  10. 二层冗余网络引起的问题