Tính tổng 2

View as PDF



Authors:
Problem types
Points: 800 Time limit: 1.0s Memory limit: 512M Input: stdin Output: stdout

Nhập vào 2 số nguyên \(n, q\).

Yêu cầu:

  • Tính tổng \(q^0 - q^1 + q^2 - q^3 + ... - q^n\). (nếu \(n\) lẻ)

  • Tính tổng \(q^0 - q^1 + q^2 - q^3 + ... + q^n\). (nếu \(n\) chẵn)

Example

Test 1

Input
2  3 
Output
7

Comments (5)

Most recent
Loading comments...