您的位置:首页 > 其它

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

2016-07-19 18:26 309 查看
/*
队友告知的题意,大概是
杯子如题摆放,有 n 层 。最上面那个杯子一秒钟可以装满,
给出 n 和时间 t ,问 t 秒后可以装满多少个杯子。

大致思路是 使用二维数组模拟杯子往下漏水的过程。

最后扫一遍数组计算容量大于 1 的个数 。

*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
using namespace std;
int main()
{
double a[15][15];
int n,t;
memset(a,0,sizeof(a));
scanf("%d%d",&n,&t);
a[1][1] = t;
for(int i=2;i<=10;i++)
{
for(int j=1;j<=10;j++)
{
double x = ( a[i-1][j]>1 ? (a[i-1][j] - 1) : 0 )/2; // 如果不够 1 既没有装满就不能继续往下漏
double y = ( a[i-1][j-1]>1 ? (a[i-1][j-1] - 1) : 0 )/2;
a[i][j] += x+y;
}
}
int ans = 0;
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
if(a[i][j]>=1) ans++;
cout<<ans<<endl;
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: