当前位置:网站首页>B. Stairs
B. Stairs
2022-08-08 16:37:00 【秦小咩】
B. Stairs
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Jett is tired after destroying the town and she wants to have a rest. She likes high places, that's why for having a rest she wants to get high and she decided to craft staircases.
A staircase is a squared figure that consists of square cells. Each staircase consists of an arbitrary number of stairs. If a staircase has nn stairs, then it is made of nn columns, the first column is 11 cell high, the second column is 22 cells high, ……, the nn-th column if nn cells high. The lowest cells of all stairs must be in the same row.
A staircase with nn stairs is called nice, if it may be covered by nn disjoint squares made of cells. All squares should fully consist of cells of a staircase.
This is how a nice covered staircase with 77 stairs looks like:
Find out the maximal number of different nice staircases, that can be built, using no more than xx cells, in total. No cell can be used more than once.
Input
The first line contains a single integer tt (1≤t≤1000)(1≤t≤1000) — the number of test cases.
The description of each test case contains a single integer xx (1≤x≤1018)(1≤x≤1018) — the number of cells for building staircases.
Output
For each test case output a single integer — the number of different nice staircases, that can be built, using not more than xx cells, in total.
Example
input
Copy
4 1 8 6 1000000000000000000
output
Copy
1 2 1 30
Note
In the first test case, it is possible to build only one staircase, that consists of 11 stair. It's nice. That's why the answer is 11.
In the second test case, it is possible to build two different nice staircases: one consists of 11 stair, and another consists of 33 stairs. This will cost 77 cells. In this case, there is one cell left, but it is not possible to use it for building any nice staircases, that have not been built yet. That's why the answer is 22.
In the third test case, it is possible to build only one of two nice staircases: with 11 stair or with 33 stairs. In the first case, there will be 55 cells left, that may be used only to build a staircase with 22 stairs. This staircase is not nice, and Jett only builds nice staircases. That's why in this case the answer is 11. If Jett builds a staircase with 33 stairs, then there are no more cells left, so the answer is 11 again.
=========================================================================
首先能用n块颜色不重叠的正方形组成的阶梯,叫做好的阶梯
然后求x块积木能够最多组成多少不同的好的阶梯
1肯定是
2构造可知不是
3一定是
4不是
再由样例,只7也是
完全可以推出只用奇数列阶梯才能满足好的阶梯,那么剩下就是贪心了
#include<iostream>
# include<algorithm>
# include<unordered_map>
using namespace std;
typedef long long int ll;
int main ()
{
int t;
cin>>t;
while(t--)
{
ll n;
cin>>n;
ll a=1;
ll ans=0;
while((a+1)*a/2<=n)
{
n-=(a+1)*a/2;
a=a*2+1;
ans++;
}
cout<<ans<<endl;
}
return 0;
}
边栏推荐
猜你喜欢
Web3构架是怎么样的?
论文解读(soft-mask GNN)《Soft-mask: Adaptive Substructure Extractions for Graph Neural Networks》
【 8.7 】 source code - card to LCM with GCD 】 【 】
linux安装部署redis&配置远程连接
ImportError: numpy.core.multiarray failed to import [cv2, matplotlib, PyTorch, pyinstaller ]
2022年中国全民健身发展白皮书
【8.7】代码源 - 【抽卡】【LCM与GCD】
JVM内存Dump原理与在线分析实战
Charles MOCK 数据 htpps代理
phar反序列化
随机推荐
使用 FasterTransformer 和 Triton 推理服务器加速大型 Transformer 模型的推理
leetcode 155. Min Stack最小栈(中等)
json根据条件存入数据库
VISTA无人驾驶模拟器;FinRL量化金融深度强化学习库;『深度神经网络应用』电子书;CUDA/TensorRT案例集锦;前沿论文 | ShowMeAI资讯日报
C语言学习概览(四)
科创人·优锘科技COO孙岗:错误问题找不到正确答案,求索万物可视的大美未来
维尔薇vs千劫
【云原生】云原生相关技术概念总结
急了,Mysql索引中最不容易记的三个知识点通透了
promise学习笔记
常见的网络安全术语之一
Kubernetes二进制部署高可用集群
国内部分手机游戏开始显示用户IP属地
Redis design and implementation notes (1)
laravel数据库: 查询构造器
抓住时代趋势,网赚新逻辑:平台+个人模式超清晰解读(附产品评测)
Spark cluster environment construction
通过jenkins交付微服务到kubernetes
使用 PyGame 的冒泡排序可视化工具
Spam accounts are a lot of trouble, and device fingerprints are quickly found