• Welcome to the world's largest Chinese hacker forum

    Welcome to the world's largest Chinese hacker forum, our forum registration is open! You can now register for technical communication with us, this is a free and open to the world of the BBS, we founded the purpose for the study of network security, please don't release business of black/grey, or on the BBS posts, to seek help hacker if violations, we will permanently frozen your IP and account, thank you for your cooperation. Hacker attack and defense cracking or network Security

    business please click here: Creation Security  From CNHACKTEAM

Recommended Posts

toh2s4lzsou3145.png

这个问题又臭又长,意思是:拿N张扑克牌搭最大的三角形,以此类推。你能造几个?

这是题为“两个难点”uv1rgada3vd3146.png

主要是两点的高度,用当前的扑克牌数作为右边界,1作为左边界。这里有一个细节,r=扑克牌的数量,l=1,因为这样写是为了保证有答案。然后就是模板。

int l=-1,r=N;

而(l 1!=r)

{

m=(l r)1;

if(check(m))l=m;

else r=m;

}

返回l或r;

难点:计算高度为h的扑克牌三角形需要多少张扑克牌,

实际上,它是垂直的:

kf3h2e0stre3147.png

从侧面看:

0ukwwufqgus3148.png

把他们两个加起来就行了。((1 h)*h h*(h-1)/2)

这些都是这个题目的难点。剩下的小细节你可以自己处理。

程序:

#includebits/stdc。h

使用命名空间std

const int N=1e6

long long t;

long long数字(long long h)

{

return(1h)* h h *(h-1)/2;

}

int main()

{

cint

while(t -)

{

龙龙s;

scanf('%d ',s);

long CNT=0;

long long r=s 1,l=0;

while(s=2)

{

cnt

long long le=1,ri=s;

long long RES=2;

while(le=ri)

{

long long mid=(le ri)/2;

if(中间数)

{

ri=中-1;

}

其他

{

res=max(res,num(mid));

le=mid 1;

}

}

s-=RES;

}

printf('%d\n ',CNT);

}

返回0;

}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now