NOI 191钉子和小球.cpp

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cstring>
 4 using namespace std;
 5 long long f[101][101];
 6 int n,m;
 7 char c;
 8 long long gcd(long long ,long long );
 9 int main()
10 {
11     scanf("%d%d",&n,&m);
12     f[1][1]=(long long)1<<n;
13     for(int i=1;i<=n;i++)
14       for(int j=1;j<=i;j++)
15       {
16           do
17         {
18               scanf("%c",&c);
19         } 
20           while(c!='*'&&c!='.');
21           if(c=='*')
22           {
23               f[i+1][j]+=f[i][j]/2;
24               f[i+1][j+1]+=f[i][j]/2;
25           }
26          else if(c=='.')
27            f[i+2][j+1]+=f[i][j];
28       }
29     long long x=gcd(f[n+1][m+1],(long long)1<<n);
30     long long k=((long long)1<<n)/x;
31     cout<<f[n+1][m+1]/x<<"/"<<k<<endl;
32     return 0;
33 }
34 long long gcd(long long x,long long y)
35 {
36     if(x%y==0)  return y;
37     return gcd(y,x%y); 
38 }

 

posted @ 2016-04-09 09:41  Minepressure  阅读(190)  评论(0编辑  收藏  举报