The state transfer matrix can be established, and N * N points are numbered 0 ~[(n-1) * n + n–1] set to Max for n * n
p = P (i, j) = [P (0, 0) p (0, 1) ... p (0, Max)
P (1, 0) p (1, 1) ... p (1, max)
...
P (max, 0) p (max, 1) ... p (max, Max)]
π (i) is the probability of the point of the I time
π (n + 1) =π (n) * P
When Time is infinite π (n + 1)->π
can be calculated by π* P =π
Verify that the guessed results are correct
*******************************************************
Finding the answers to the rules remains to be proved
Now we can think of the whole closed-systems. Each lattice has the probability of a robot appearing as a weight value over a long time line is an entropy increase
Process (think of cellular automata), if you want to simulate the process of probability diffusion, the update of the lattice's weights is a weighted value of the lattice he can reach.
And the process of his own weight-value iteration, the process can be found that the weights of his neighboring lattices are constantly assimilated, and therefore, after infinity
(0, 0) and the weight of the lattice around him are not the dominant, while the more open lattice is more dominant (can be understood according to the iterative formula)
*******************************************************
Considering the effect of each obstacle point on the answer, finding the rule is only related to the location of the obstacle point and the surrounding unicom situation.
Check if the grid is not a barrier can use set
1#include <cstdio>2#include <cstring>3#include <string>4#include <cmath>5#include <iostream>6#include <algorithm>7#include <map>8#include <Set>9#include <queue>Ten#include <vector> One using namespacestd; AtypedefLong Longll; -typedef unsignedint UINT; -typedef unsignedLong Longull; thetypedef pair<int,int>PII; -typedef vector<int>VI; - #defineFi first - #defineSe Second + #defineMP Make_pair - #defineN 11000 + #defineM 210 A #defineMOD 1e9+7 at #defineEPS 1e-8 - #definePi ACOs (-1) - intdx[]={0,-1,1,0,0},dy[]={0,0,0,-1,1}; - Set<int>St; - - in intRead () - { to intv=0, f=1; + CharC=GetChar (); - while(c< -|| $<C) {if(c=='-') f=-1; C=GetChar ();} the while( -<=c&&c<= $) v= (v<<3) +v+v+c- -, c=GetChar (); * returnv*F; $ }Panax Notoginseng - intgcdintXinty) the { + if(y==0)returnx; A returnGCD (y,x%y); the } + - intMain () $ { $ //freopen ("hdoj6229.in", "R", stdin); - //freopen ("Hdoj6299.out", "w", stdout); - intCAs; thescanf"%d",&CAs); - for(intv=1; v<=cas;v++)Wuyi { the st.clear (); - intn,m; Wuscanf"%d%d",&n,&m); - for(intI=1; i<=m;i++) About { $ intx, y; -scanf"%d%d",&x,&y); -St.insert (x*n+y); - } A ints1=n*n*5-n*4; + ints2=n* (n+1)/2*5-2*n-2; the Set<int>::iterator t=St.begin (); - while(t!=st.end ()) $ { the ints=*T; the intx=s/N; the inty=s%N; the for(intI=1; i<=4; i++) - { in inttx=x+Dx[i]; the intty=y+Dy[i]; the if(tx<0|| tx>=n| | ty<0|| ty>=n| | St.count (Tx*n+ty))Continue; Abouts1--; the if(tx+ty>=n-1) s2--; the } the + if(x+y>=n-1) - { thes2-=5;Bayi if(x==0|| x==n-1) s2++; the if(y==0|| y==n-1) s2++; the } - -s1-=5; the if(x==0|| x==n-1) s1++; the if(y==0|| y==n-1) s1++; thet++; the } - the intk=gcd (S1,S2); theprintf"Case #%d:%d/%d\n", v,s2/k,s1/k); the } 94 return 0; the } the