Codeforces Round #354 (Div. 2) B
来源:互联网 发布:vb音乐播放器 编辑:程序博客网 时间:2024/05/16 08:02
Codeforces Round #354 (Div. 2) B
B. Pyramid of Glasses
题意:把n层杯子排成金字塔形,第n层有n个杯子,每秒加一杯水,问t秒后多少杯子水满了。
思路:这里有一个整体与部分的思维,我们把一杯一杯的水看做是整体的t杯水同时倒在1号杯子上(假设不洒),然后比一多的,就分流到下面的杯子上,下面的每个杯子可以获得它左上和右上的1/2(注意边界处理)。
#include <iostream> #include <cstdlib> #include <algorithm> using namespace std; double a[13][13]; int main(){int n,t; cin >> n >> t; a[1][1] = t; for (int i = 1; i <= n; i++){for (int j = 1; j <= n; j++){if (a[i][j] >= 1.0){double k = a[i][j]-1; k /= 2; a[i+1][j] += k, a[i+1][j+1] += k; }}}int cnt = 0; for (int i = 1; i <= n; i++){for (int j = 1; j <= n; j++){if (a[i][j] >= 1.0) cnt++; }}cout << cnt << endl;return 0; }注意思维方法的使用:1逆向思维
2.整体与部分
3.抽象思维,解开问题本质,把问题转换为另一个问题
0 0
- Codeforces Round #354 (Div. 2) B
- Codeforces Round #354 (Div. 2)676B. Pyramid of Glasses
- Codeforces Round #354 (Div. 2)(B)模拟
- Codeforces Round #354 (Div. 2) A 、B、C
- Codeforces Round #354 (Div. 2) B (模拟)
- Codeforces Round #354 (Div. 2) A B C
- Codeforces Round #354 (Div. 2)(A && B && C)
- Codeforces Round #131 (Div. 2) A B
- Codeforces Round #134 (Div. 2)B. Airport
- Codeforces Round #170 (Div. 2) problem B
- Codeforces Round #173 (Div. 2) Problem B
- Codeforces Round #181 (Div. 2) B. Coach
- Codeforces Round #185 (Div. 2)--A,B
- Codeforces Round #171 (Div. 2) B
- Codeforces Round #169 (Div. 2) B题
- Codeforces Round #188 (Div. 2) B题
- Codeforces Round #192 (Div. 2) B
- Codeforces Round #203 (Div. 2) B. Resort
- 抽象工厂模式-与-工厂方法模式区别
- 第十三周实践项目-阅读程序,写出运算结果(1)
- 第十十一周继承与派生1
- C++初探:c和c++的区别简述,以及编译器对代码做了什么?
- linux sort 命令详解
- Codeforces Round #354 (Div. 2) B
- 第8周项目3- 指向学生类的指针
- 第十一周阅读项目(2)
- 阅读程序2
- 百度apistore开发实例
- Dispatcher介绍
- 第十二周项目2—Time类中的运算符重载
- 第十三周项目1:阅读程序,并写出运行结果(1)虚函数
- 第12周项目1—实现复数类的运算符重载 (1)