Xếp que diêm

View as PDF

Submit solution

Points: 1.00 (partial)
Time limit: 1.0s
Memory limit: 256M
Input: stdin
Output: stdout

Problem type
Allowed languages
Python, Scratch

Ban tổ chức đưa ra cho các thí sinh một trò chơi: dùng ~N~ que diêm của ban tổ chức đã chuẩn bị để xếp thành lưới tam giác như hình trên thì có thể xếp được tam giác có nhiều nhất bao nhiêu tầng (chỉ tính tầng đã hoàn thiện).

Dữ liệu
  • Gồm một dòng chứa một số tự nhiên ~N~ ~(N ≤ 10^{15})~ là số que diêm mà ban tổ chức đã chuẩn bị.
Kết quả
  • Gồm một dòng chứa một số tự nhiên là kết quả của bài toán.
Chấm điểm
  • Có 50% số test ứng với 50% số điểm có: ~N ≤ 10^6~;
  • 50% số test còn lại ứng với 50% số điểm không có ràng buộc gì thêm.
Sample Input 1
10
Sample Output 1
2
Note 1
  • Xếp được ~2~ tầng thì hết ~9~ que diêm, que diêm thứ ~10~ xếp sang tầng thứ ~3~ nhưng tầng đó chưa hoàn thiện nên không tính.
Sample Input 2
18
Sample Output 2
3
Note 2
  • ~18~ que diêm xếp trọn vẹn được ~3~ tầng.

Comments

Please read the guidelines before commenting.



  • -1
    nam12345  commented on April 22, 2025, 2:01 p.m.

    Code nè: from math import* n=int(input()) k=int(sqrt(n2/3))+1 while 3(1+k)*k/2>n: k-=1 print(k)


  • -8
    caophong  commented on April 22, 2025, 9:29 a.m.

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


  • -13
    buiducduy2014  commented on April 20, 2025, 2:15 a.m.

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


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

    from math import* n=int(input()) k=int(sqrt(n2/3))+1 while 3(1+k)*k/2>n: k-=1 print(k)


  • -13
    buiducduy2014  commented on April 20, 2025, 2:14 a.m.

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


  • -8
    nguyenvu0511  commented on April 19, 2025, 3:44 a.m.

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


  • -8
    nguyenvu0511  commented on April 19, 2025, 3:44 a.m.

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


  • -10
    nguyenvu0511  commented on April 19, 2025, 3:44 a.m.

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


  • -10
    nguyenvu0511  commented on April 19, 2025, 3:43 a.m.

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


  • -6
    buiducduy2014  commented on April 15, 2025, 1:59 p.m.

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


  • -12
    THTBH_Bang  commented on April 13, 2025, 9:14 a.m.

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


  • -14
    nguyenkhang2008  commented on April 12, 2025, 3:06 a.m.

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


  • -13
    huynhtrithinh10  commented on April 10, 2025, 2:37 p.m.

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


  • -11
    vungocgiang4bthnh  commented on April 7, 2025, 2:15 a.m.

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


  • -9
    hoangnam2572014  commented on April 4, 2025, 10:09 a.m.

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


  • -7
    nguyenkhang2008  commented on April 3, 2025, 2:55 p.m.

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


  • -8
    nguyenkhang2008  commented on April 3, 2025, 2:54 p.m.

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


  • -6
    nguyenkhang2008  commented on April 3, 2025, 2:54 p.m.

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


  • -7
    nguyenkhang2008  commented on April 3, 2025, 2:51 p.m.

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