当前位置:网站首页>Card constructions -- two points
Card constructions -- two points
2022-06-13 00:32:00 【P1n9】
Card Constructions
https://codeforces.com/problemset/problem/1345/B
< Ideas >
Dichotomy h
from sys import stdin
def binary_search(val):
i, j = 1, 100000
while i < j:
mid = i + (j - i) / 2
mid = int(mid)
ptr = (3 * mid * mid + mid) // 2
if ptr <= val:
i = mid + 1
else:
j = mid
return i - 1
t = int(stdin.readline())
for _ in range(t):
n = int(stdin.readline())
ans = 0
tmp = n
while(True):
ans = ans + 1
h = binary_search(tmp)
if h == 0:
break
tmp = tmp - (3 * h * h + h) // 2
print(ans - 1)
边栏推荐
- 中科大USTC:Minrui Wang | 基于Transformer的多智能体强化学习的配电网稳压
- C language standard IO, such as printf(), scanf(), etc
- Using fastjson to solve the problem of returning an empty array from a null value of a field string object
- [supersocket 2.0] supersocket 2.0 from the beginning to the end
- 2022 beautician (technician) certificate title and answer
- APISpace 空号检测API接口 免费好用
- PMP test difficulty and pass rate
- 睡前小故事之MySQL起源
- How to visit a website
- 6.824 Lab 4B: Sharded Key/Value Service
猜你喜欢

The difference between caching and buffering

On the parameters of main function in C language

MySQL index

String类中split()方法的使用

What occupation is suitable for PMP?
![BUUCTF之BabySQL[极客大挑战 2019]](/img/6c/957e5e09f252210d0b4cf8771d4ade.png)
BUUCTF之BabySQL[极客大挑战 2019]

Test platform series (97) perfect the case part

1. Google grpc framework source code analysis Hello World

A detailed explanation of synchronized

Is the revised PMP worth testing?
随机推荐
[matlab] matrix transformation and matrix evaluation
TypeError: wave.ensureState is not a function
[LeetCode]21. Merge two ordered linked lists twenty-nine
[LeetCode]20. Valid parentheses thirty-six
June 13, 2022 Daily: Turing prize winner: what should we pay attention to if we want to succeed in our academic career?
Learn to divide subnets in an article
vs studio_ How to use scanf in 2022
2022施工員-設備方向-通用基礎(施工員)操作證考試題及模擬考試
Is the newly graduated college student taking BEC or PMP? PM who wants to transfer to another job in the future
如何快速查询手机在网状态
[matlab] basic knowledge
Will the salary increase after obtaining PMP certification?
Masa auth - overall design from the user's perspective
APISpace 空号检测API接口 免费好用
Is the revised PMP worth testing?
Make the tasks in the scheduled task XXL job flexible
Information collection for network security (2)
Test platform series (97) perfect the case part
Lambda expression
Go custom collation