UVa 10934-dropping Water Balloons (DP)

Source: Internet
Author: User

Give the n The same balloon, k Floors, ask at least a few experiments can know how many balloons from the top of the drop will not explode.
Use d[i][J] Represents the use i A ball, an experiment. J The maximum number of floors that can be determined, for each trial split and non-explosive two cases of discussion:
1, burst, transferred to d [I?1][J ?1]+1 , with 1 balls and an experimental opportunity.
2, no explosion, the current test layer of the previous layer as the 1th layer continues to test, transferred to d [I][J ?1] 。
To derive the transfer equation d [I][J ]=d [I?1][J ?1]+1+d [I][J ?1] 。
Long time ago To do the problem, specific ideas see purple Book.

#include <cstdio>#include <cstring>#include <algorithm>using namespace STD;typedef unsigned Long LongULL; ULL d[ the][ $],k,n;intMain () { for(intI=1;i< the; ++i) for(intj=1;j< $; ++j) d[i][j]=d[i-1][j-1]+1+d[i][j-1]; while(~scanf("%llu%llu", &k,&n) &&k) {intAns =0; for(intI= -; i>=0;-I.)if(d[k][i]<n) {ans=i+1; Break; }if(ans<= the)printf("%d\n", ans);Else puts("More than trials needed."); }return 0;}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

UVa 10934-dropping Water Balloons (DP)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.