Submission #19901

# Submission time Handle Problem Language Result Execution time Memory
19901 2016-02-25T06:52:29 Z xhae 흑백 (kriii4_G) C++14
0 / 100
0 ms 5628 KB
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <sstream>
#include <set>
using namespace std;

const int max_n = 1000;
const int mmod = 1000000007;

int pw2[max_n*max_n+1];

	int inv_mod(int a, int b) {
		if (a == 1) return b;
		int div = mmod / a + 1;
		return inv_mod((a * (long long)div) % mmod, (b * (long long)div) % mmod);
	}

int main()
{
  int h, w;
  cin >> h >> w;

  pw2[0] = 1;
  for (int i=0; i<h*w; i++)
    pw2[i+1] = (pw2[i] * 1LL * 2) % mmod;

  int res = 0;
  for (int bx1=0; bx1<w; bx1++)
    for (int bx2=bx1; bx2<w; bx2++)
      for (int by1=0; by1<h; by1++)
        for (int by2=by1; by2<h; by2++)
  for (int wx1=0; wx1<w; wx1++)
    for (int wx2=wx1; wx2<w; wx2++)
      for (int wy1=0; wy1<h; wy1++)
        for (int wy2=wy1; wy2<h; wy2++)
          if (wx2 < bx1 || bx2 < wx1 || wy2 < by1 || by2 < wy1)
            res = (res + pw2[h*w-(bx2-bx1+1)*(by2-by1+1)-(wx2-wx1+1)*(wy2-wy1+1)]) % mmod;
  res = (res * 1LL * inv_mod(pw2[h*w], 1)) % mmod;
  printf("%d\n", res);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5628 KB Output is correct
2 Correct 0 ms 5628 KB Output is correct
3 Incorrect 0 ms 5628 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Halted 0 ms 0 KB -