Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
这就是模拟吧。。。#include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> using namespace std; typedef long long lint; lint map[55][55]; int n,m; char s[55][110]; bool vis[55][55]; int main() { scanf("%d%d\n",&n, &m); for(int i = 1; i <= n; i++) gets(s[i]); for(int i = 1; i <= n; i++) for(int j = 0,cnt = 0;s[i][j] != '\0'; j++) if(s[i][j] == '*' || s[i][j] == '.') { cnt++; if(s[i][j] == '.') vis[i][cnt] = true; } map[1][1] = (lint)1<<n; for(int i = 1; i <= n; i++) for(int j = 1; j <= i; j++) { if(vis[i][j]) map[i+2][j+1] += map[i][j]; else { map[i+1][j] += map[i][j]>>1; map[i+1][j+1] += map[i][j]>>1; } } if(map[n+1][m+1] == 0) printf("0/1\n"); else { while(!(map[n+1][m+1]&1)) map[1][1] >>= 1,map[n+1][m+1] >>= 1; printf("%lld/%lld",map[n+1][m+1],map[1][1]); } //system("pause"); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator