#C12264. Sum of Powers
Sum of Powers
Sum of Powers
Given two integers n and k, compute the sum \(\sum_{i=1}^{n} i^k\). In other words, you need to find the sum of the first n positive integers, each raised to the power of k. For example, when \(n = 3\) and \(k = 2\), the result is \(1^2 + 2^2 + 3^2 = 14\).
inputFormat
The input consists of a single line containing two space-separated integers \(n\) and \(k\) \(\,(1 \le n \le 10^5, \, 0 \le k \le 10)\). You have to compute \(\sum_{i=1}^{n} i^k\).
outputFormat
Output a single integer representing the sum \(\sum_{i=1}^{n} i^k\).
## sample3 2
14