Connection Status:
Competition Arena > PowSum
TCO '03 Round 1 · 2003-10-07 · by lars2520 · Simple Math
Class Name: PowSum
Return Type: int
Method Name: getSum
Arg Types: (int, int, int)
Problem Statement

Problem Statement

Given an int low, an int high, and an int pow, return the sum of i^j, for all i between low and high, inclusive, and all j between 1 and pow, inclusive.

Constraints

  • low will be between -100 and 100, inclusive.
  • high will be between low and 100, inclusive.
  • pow will be between 1 and 10, inclusive.
  • The return value will fit in a signed 32 bit datatype.
Examples
0)
1
3
2
Returns: 20

1^1 + 2^1 + 3^1 + 1^2 + 2^2 + 3^2 = 1 + 2 + 3 + 1 + 4 + 9 = 20

1)
-12
12
9
Returns: 1637738440

Note that intermediate values may exceed the 32 bit restriction.

2)
-100
100
2
Returns: 676700
3)
-43
64
3
Returns: 3549492
4)
-87
87
5
Returns: 2051859040

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

Coding Area

Language: C++17 · define a public class PowSum with a public method int getSum(int low, int high, int pow) · 60 test cases · 2 s / 256 MB per case

Submitting as anonymous