NC24825. [USACO 2009 Feb B]Cruel Math Teacher, I
描述
By way of example, 2 to the power 3 = 2 * 2 * 2 (three times) = 8. Similarly, 123456 to the power 88 = 123456 * 123456 * ... * 123456 (88 times) = 1129987770413559019467963153621658978635389622595924947762339599136126 3387265547320084192414348663697499847610072677686227073640285420809119 1376617325522768826696494392126983220396307144829544079751988205731569 1498433718478969549886325738202371569900214092289842856905719188890170 0772424218248094640290736200969188059104939824466416330655204270246371 3699112106518584413775333247720509274637795508338904731884172716714194 40898407102819460020873199616 when printed 70 digits per line.
输入描述
* Line 1: Two space-separated integers: N and P
输出描述
* Lines 1..?: A single integer that is the result of the calculation. Print 70 digits per line except potentially for the last line, which might be shorter.
示例1
输入:
2 15
输出:
32768
Java 解法, 执行用时: 46ms, 内存消耗: 12480K, 提交时间: 2021-10-14 20:37:10
import java.util.*; import java.math.*; import java.text.*; public class Main{ public static void main(String args[]){ Scanner cin= new Scanner(System.in); BigInteger a; int b,c; a = cin.nextBigInteger(); b = cin.nextInt(); a = a.pow(b); System.out.println(a); } }
Python3(3.5.2) 解法, 执行用时: 30ms, 内存消耗: 6388K, 提交时间: 2019-09-26 10:39:17
n,m=map(int,input().split()) print(n**m)