제출 #19927

#제출 시각아이디문제언어결과실행 시간메모리
19927xhae흑백 (kriii4_G)C++14
6 / 100
2000 ms5640 KiB
#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 fac[max_n+1]; int inv_fac[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 combi(int a, int b) { return (1LL * fac[a] * inv_fac[b] % mmod * inv_fac[a-b]) % 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] * 2LL) % mmod; fac[0] = inv_fac[0] = 1; for (int i=1; i<=max_n; i++) { fac[i] = (fac[i-1] * 1LL * i) % mmod; inv_fac[i] = inv_mod(fac[i], 1); } int res = 0; for (int x1=1; x1<=h; x1++) for (int x2=1; x1+x2<=h; x2++) for (int y1=1; y1<=w; y1++) for (int y2=1; y1+y2<=w; y2++) { res = (res + 1LL * combi(h, x1) * combi(h-x1, x2) % mmod * combi(w, y1) % mmod * combi(w-y1, y2) % mmod * pw2[h*w-x1*y1-x2*y2]) % mmod; } for (int x1=1; x1<=h; x1++) for (int y1=1; y1<=w; y1++) for (int x_common=1; x_common<=x1; x_common++) for (int x2=x_common; x1+x2<=h+x_common; x2++) for (int y2=1; y1+y2<=w; y2++) { res = (res + 1LL * combi(h, x1) * combi(x1, x_common) % mmod * combi(h-x1, x2-x_common) % mmod * combi(w, y1) % mmod * combi(w-y1, y2) % mmod * pw2[h*w-x1*y1-x2*y2]) % mmod; } for (int x1=1; x1<=h; x1++) for (int y1=1; y1<=w; y1++) for (int y_common=1; y_common<=y1; y_common++) for (int y2=y_common; y1+y2<=w+y_common; y2++) for (int x2=1; x1+x2<=h; x2++) { res = (res + 1LL * combi(h, x1) * combi(h-x1, x2) % mmod * combi(w, y1) % mmod * combi(y1, y_common) % mmod * combi(w-y1, y2-y_common) % mmod * pw2[h*w-x1*y1-x2*y2]) % mmod; } res = (res * 1LL * inv_mod(pw2[h*w], 1)) % mmod; printf("%d\n", res); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...