Codeforces Round #354 (Div. 2)-B. Pyramid of Glasses

Source: Internet
Author: User

/*teammates told the test instructions, probably the Cup title placed, there are n layers. The top of the cup can fill a second, give N and time t, ask t seconds can fill how many cups. The idea is to use a two-dimensional array to simulate the process of a cup leaking down. Finally sweep the array to calculate the number of capacity greater than 1. */#include<cstdio>#include<cstring>#include<algorithm>#include<iostream>#include<string>using namespacestd;intMain () {Doublea[ the][ the]; intn,t; Memset (A,0,sizeof(a)); scanf ("%d%d",&n,&t); a[1][1] =T;  for(intI=2; i<=Ten; i++)    {         for(intj=1; j<=Ten; j + +)        {            Doublex = (a[i-1][j]>1? (a[i-1][J]-1) :0)/2;//if it's not enough, 1 can't keep leaking if it's not filled.            Doubley = (a[i-1][j-1]>1? (a[i-1][j-1] -1) :0)/2; A[I][J]+ = x+y; }    }    intAns =0;  for(intI=1; i<=n;i++)         for(intj=1; j<=n;j++)            if(a[i][j]>=1) ans++; cout<<ans<<Endl; return 0;}

Codeforces Round #354 (Div. 2)-B. Pyramid of Glasses

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.