题目:
http://codeforces.com/problemset/problem/676/B
大神代码
1 #include <cstdio> 2 using namespace std; 3 double dp[15][15]; 4 int main() 5 { 6 int n,t,ans=1; 7 scanf("%d%d",&n,&t); 8 dp[1][1]=t; 9 for (int i=2;i<=n;i++) 10 for (int j=1;j<=i;j++) 11 { 12 if (dp[i-1][j-1]>1) 13 dp[i][j]+=(dp[i-1][j-1]-1)/2; 14 if (dp[i-1][j]>1) 15 dp[i][j]+=(dp[i-1][j]-1)/2; 16 if (dp[i][j]>=1) ans++; 17 } 18 printf("%d ",t==0?0:ans); 19 }
弱鸡代码
1 #include <bits/stdc++.h> 2 using namespace std; 3 #define ll long long 4 const ll maxn=1e5+10; 5 double a[20][20]; 6 int main(){ 7 ll n,m,num=0; 8 memset(a,0,sizeof(a)); 9 cin>>n>>m; 10 a[1][1]=m; 11 if(a[1][1]>=1) num++; 12 for(int i=2;i<=n;i++){ 13 for(int j=1;j<=i;j++){ 14 if(a[i-1][j-1]>1) 15 a[i][j]+=(a[i-1][j-1]-1)/2; 16 if(a[i-1][j]>1) 17 a[i][j]+=(a[i-1][j]-1)/2; 18 if(a[i][j]>=1) num++; 19 } 20 } 21 cout<<num<<endl; 22 }
只有不断学习才能进步!