TS10 Tiền Giang 2025 - Tính tổng

View as PDF

Submit solution

Points: 5.00 (partial)
Time limit: 1.0s
Memory limit: 1G
Input: stdin
Output: stdout

Problem type
Allowed languages
C, C++, Java, Output Only, Pascal, PyPy, Python, Scratch, TEXT

Với số nguyên dương ~n~. Em hãy tính tổng ~S~, với công thức tính S như sau:

  • ~S = 1 + 3 + 5 + … + n~, nếu ~n~ lẻ.

  • ~S = 2 + 4 + 6 + … + n~, nếu ~n~ chẵn.

Input

Một dòng duy nhất là só nguyên ~n~ ~(1 \le n \le 10^9)~

Output

In ra tổng ~S~ vừa tìm

Sample Input

5

Sample Output

9

Subtask

  • Có ~60\%~ test với ~1 \le n \le 10^6~.

  • Có ~40\%~ test với ~10^6 < n \le 10^9~.


Comments

Please read the guidelines before commenting.


There are no comments at the moment.