Submit solution
Points:
1.00 (partial)
Time limit:
1.0s
Memory limit:
512M
Input:
stdin
Output:
stdout
Author:
Problem type
Allowed languages
Python, Scratch
Cho dãy số có quy luật như sau:
~1~ , ~2~ , ~2~ , ~3~ , ~3~ , ~3~ , ~4~ , ~4~ , ~4~ , ~4~ , ~5~ , ~5~ , ~5~ , ~5~ , ~5~ , ~...~
Yêu cầu: Cho số nguyên dương ~N~, hãy tính tổng ~N~ số đầu tiên của dãy.
Dữ liệu
- Một dòng chứa một số nguyên dương ~N~ ~(1 \le N \le 10^9)~.
Kết quả
- Một số nguyên là tổng ~N~ số đầu tiên của dãy.
Sample Input
5
Sample Output
11
Comments
cứu với
import math def tongdaycongthuc(n): m = int((math.isqrt(8 * n + 1) - 1) // 2) used = m * (m + 1) // 2 r = n - used tongbinhphuong = m * (m + 1) * (2 * m + 1) // 6 tong = tongbinhphuong + (m + 1) * r return tong n = int(input()) ketqua = tongdaycongthuc(n) print(ketqua)
khó quá đi
cứu với
.
.
huhu
This comment is hidden due to too much negative feedback. Show it anyway.
cứu
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
alo
cứu với
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.