Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <cstdlib>
- #include <cassert>
- #include <cstring>
- using namespace std;
- typedef long double ld;
- ld m[1<<6][1<<6],h[1<<6][1<<6];
- int init[1<<3][1<<3];
- int dx[] = {-1,-1,0,1,1,1,0,-1};
- int dy[] = {0,1,1,1,0,-1,-1,-1};
- const int wh = 43;
- inline void mul(){
- for(int i=0;i<64;++i) {
- for(int j=0;j<64;++j){
- h[i][j]=m[i][j]; m[i][j]=0;
- }
- }
- for(int i=0;i<64;++i){
- for(int j=0;j<64;++j) {
- for(int k= 0;k<64;++k) {
- m[i][j]+=h[i][k]*h[k][j];
- }
- }
- ld n=0;
- for(int j=0;j<64;++j) {
- n+=m[i][j];
- }
- for(int j=0;j<64;++j) {
- m[i][j]/=n;
- }
- }
- }
- inline bool in_board(int x, int y) { return x < 8 && y < 8 && x>=0 && y>=0;}
- int main(){
- int x,y;
- for(int i=0;i<8;++i) {
- for(int j=0;j<8;++j) {
- cin>>init[i][j];
- }
- }
- for(int i=0;i<8;++i) {
- for(int j=0;j<8;++j){
- int n = 0;
- for(int k=0;k<8;++k){
- if (in_board(x=i+dx[k],y=j+dy[k])) {
- n+=init[x][y];
- }
- }
- for(int k=0;k<8;++k){
- if (in_board(x=i+dx[k],y=j+dy[k])){
- m[i*8+j][x*8+y]=(ld)init[x][y] / n;
- }
- }
- }
- }
- for(long long a=1LL<<40; a; a>>=1){
- mul();
- }
- for(int i=0;i<64;++i){
- printf("%.12Lf ",m[wh][i]);
- if (i%8==7) printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment