Tổng dãy số theo nhóm

View as PDF

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

Please read the guidelines before commenting.



  • 1
    nthai6  commented on April 26, 2025, 12:39 a.m.

    cứu với


  • -3
    hehehaha0047  commented on April 22, 2025, 2:15 p.m.

    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)


  • -2
    HoNgocNguyenKhang270813  commented on April 22, 2025, 2:02 p.m.

    khó quá đi


  • -2
    HoNgocNguyenKhang270813  commented on April 22, 2025, 2:02 p.m.

    cứu với


  • -3
    Kaiser  commented on April 21, 2025, 1:04 p.m.

    .


  • -3
    Kaiser  commented on April 21, 2025, 1:03 p.m.

    .


  • -2
    ngominhnhat  commented on April 21, 2025, 11:34 a.m.

    huhu


  • -6
    nthai6  commented on April 21, 2025, 11:34 a.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


  • -3
    ngominhnhat  commented on April 21, 2025, 11:29 a.m.

    cứu


  • -11
    dopdopyesyes2k14  commented on April 20, 2025, 10:00 a.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


  • -9
    dopdopyesyes2k14  commented on April 20, 2025, 10:00 a.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


  • -7
    ngominhnhat  commented on April 20, 2025, 2:46 a.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


  • -12
    buiducduy2014  commented on April 20, 2025, 2:46 a.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


  • -2
    Sae  commented on April 20, 2025, 2:38 a.m.

    alo


  • -4
    ngominhnhat  commented on April 20, 2025, 2:38 a.m.

    cứu với


  • -11
    buiducduy2014  commented on April 20, 2025, 2:38 a.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


  • -19
    nguyenvu0511  commented on April 14, 2025, 12:48 p.m. edited

    This comment is hidden due to too much negative feedback. Show it anyway.