题目连接:http://codeforces.com/contest/676/problem/B
题意:给你一个N层的杯子堆成的金字塔,倒k个杯子的酒,问倒完后有多少个杯子的酒是满的
题解:由于数据不是很大,直接模拟就行了
1 #include<cstdio> 2 #include<cstring> 3 #define F(i,a,b) for(int i=a;i<=b;++i) 4 5 double a[15][15],eps=1e-9,p;int n,k,ans; 6 7 void fuck(){ 8 a[1][1]+=1; 9 F(i,1,n-1)F(j,1,i) 10 if(a[i][j]-1>eps)p=a[i][j]-1,a[i][j]=1,a[i+1][j]+=p/2,a[i+1][j+1]+=p/2; 11 } 12 13 int main(){ 14 while(~scanf("%d%d",&n,&k)){ 15 memset(a,0,sizeof(a)); 16 F(i,1,k)fuck();ans=0; 17 F(i,1,n)F(j,1,i)if(a[i][j]>1-eps)ans++; 18 printf("%d ",ans); 19 } 20 return 0; 21 }