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; }
相关文章推荐
- 初试Celery
- Android仿微信,上传本地多张图片,缩放预览,以及图片处理等
- 小记——linux线程
- 读取文本文件中文每一行并存储到txt
- 【Unity】Unity下载器下载不下IOS/Android等模块的解决办法
- MySQL执行SHOW STATUS查询服务器状态状态之Handler_read_* 详解
- Eclipse for j2ee 无法调式问题
- 21副GIF动图让你了解各种数学概念
- NavigationController 自定义pop和push动画
- HTTP 方法:GET 对比 POST
- postgresql 时间函数j2day
- Android 动画之ScaleAnimation应用详解
- THE HANDLER_READ_* STATUS VARIABLES
- 伸展树
- fLNK1123: 转换到 COFF 期间失败: 文件无效或损坏 解决方案
- 机器学习2 梯度下降
- 随便唠叨一下...
- iOS正则表达式
- LeetCode Perfect Squares(动态规划)
- android中ScrollView常用属性汇总