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

题目链接:http://codeforces.com/problemset/problem/676/B
题意:有一个n层的酒杯架,每层有n个酒杯,样子跟图片一样。一个人倒酒t秒,一秒倒能装满一杯的酒,求t秒后有多少个满酒杯
思路:
暴力大法好
枚举一下每层的酒杯就好了

#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define lowbit(x) (x&(-x))
typedef long long LL;
const int maxn = 10005;
const int inf=(1<<28)-1;
int C[15][15];
double A[15][15];
int n;
void dfs(int pos)
{
    if(pos==n+1) return ;
    int x=pos;
    for(int i=1;i<=pos;++i)
    {
        int y=i;
    if(A[x][y])
    {
        if(C[x][y]==0&&A[x][y]>=1)
        {
            C[x][y]=1;
            A[x][y]-=1;
        }
        if(C[x][y]&&A[x][y]!=0)
        {
            if(y==1)
            {
                A[x+1][y]+=A[x][y]/2;
            }
            else A[x+1][y-1]+=A[x][y]/2;
            A[x+1][y+1]+=A[x][y]/2;
            A[x][y]=0;
        }
    }
    }
    dfs(pos+1);
}
int main()
{
    A[1][1]=1;
     int t;
    scanf("%d%d",&n,&t);
    A[1][1]=t;
    dfs(1);
    int ans=0;
    for(int i=1;i<=n;++i)
     for(int j=1;j<=i;++j)
     ans+=C[i][j];
    printf("%d\n",ans);
    return 0;
} 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值