Connection Status:
Competition Arena > SumOfPowers
SRM 397 · 2008-04-12 · by mateuszek · Advanced Math
Class Name: SumOfPowers
Return Type: int
Method Name: value
Arg Types: (int, int)
Problem Statement

Problem Statement

NOTE: This problem statement contains superscripts that may not display properly if viewed outside of the applet.


You are given ints n and k. Return the value of the sum 1k + 2k + 3k + ... + nk modulo 1000000007.

Constraints

  • n will be between 1 and 109, inclusive.
  • k will be between 1 and 50, inclusive.
Examples
0)
5
1
Returns: 15

Here, we have arithmethic progression: 1 + 2 + 3 + 4 + 5 = 15.

1)
4
2
Returns: 30

Just a little bit more complicated example here: 12 + 22 + 32 + 42 = 1 + 4 + 9 + 16 = 30.

2)
13
5
Returns: 1002001

This one would be harder to check by hand.

3)
1000000000
50
Returns: 16605204
4)
1000000000
49
Returns: 642472098

Submissions are judged against all 89 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class SumOfPowers with a public method int value(int n, int k) · 89 test cases · 2 s / 256 MB per case

Submitting as anonymous