日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python 编码问题_Python电源挑战| 竞争编码问题

發(fā)布時間:2025/3/11 python 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python 编码问题_Python电源挑战| 竞争编码问题 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

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.

一種功率函數(shù)是可以表示為x ^ X,X加注到x的功率即正數(shù),其中x是任意正數(shù)。 您將得到一個整數(shù)數(shù)組A,并且如果數(shù)組A的元素是否為Power Number,則需要打印。

Input:

輸入:

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

第一行包含N ,一個正整數(shù)。 下一行包含N個空格-分隔的整數(shù)。

31 3 4

Output:

輸出:

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

對于每個整數(shù),如果是冪數(shù),則打印“ Yes” ,否則打印“ No” 。 這些輸出必須用空格分隔。

Yes No Yes

Constraints:

限制條件:

1 <= N <= 1001 <= 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.

在這個問題中,我們必須檢查數(shù)組中給定的數(shù)字是否為冪數(shù)。 我們將在python中的冪函數(shù)的幫助下找到它。 因此,我們可以通過將每個元素與冪數(shù)進行比較來做到這一點,因此首先我們從用戶那里獲取輸入并創(chuàng)建大小為N的數(shù)組。 然后制作另一個存儲從1到14的冪數(shù)的數(shù)組。這個問題的重點是約束。 在這個問題中,給出的約束直到10 ^ 16個數(shù)字。

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 arrayBrr.append(pow(i, i)) for i in range(N):# compare the give array with # power number array one by oneif(Arr[i] in Brr):# if it matches print Yes other wise NOprint('Yes', end=' ') else:print('No', end=' ')

Output

輸出量

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

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

python 編碼問題

創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎

總結(jié)

以上是生活随笔為你收集整理的python 编码问题_Python电源挑战| 竞争编码问题的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。