⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1189.c

📁 acm-pku-1189 钉子和小球 北大acm自做题解
💻 C
字号:
#include <stdio.h>
#include <math.h>

double temp[101]={0};
__int64 first=1;
__int64 a,a1,b,t;

int main(void)
{

    int n,m,i,j,k,h,l;
	char get;
    scanf("%d %d",&n,&m);
	b=first=first<<n;

	for(;;)
	{
		scanf("%c",&get);
		if(get!=' '&&get!='\n') break;
	}

	if(get=='*')  temp[49]=temp[51]=0.5;
	else          temp[50]=1;
    
	for(j=49,k=2;k<=n;k++)
	{ 
		h=j;
		for(l=1;l<=k;)
		{
			scanf("%c",&get);
			if(get==' '||get=='\n') continue;
			if(get=='*') 
			{
				temp[h-1]=temp[h]*0.5+temp[h-1];
				temp[h+1]=temp[h]*0.5+temp[h+1];
				temp[h]=0;
			}
			h=h+2;
			l++;
		}
		j--;
	}

	a1=a=temp[50-n+m*2]*first;

	if(a==0) printf("0/1\n");
	else
	{
		for(;;)
		{
			if(b%a) 
			{
				t=b%a;
				b=a;
				a=t;
			}
			else break;
		}
		printf("%I64d/%I64d\n",a1/a,first/a);
	}	
    return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -