Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #pragma GCC optimize("Ofast,fast-math,unroll-loops")
- #pragma GCC target("sse,sse2,sse3,ssse3,sse4,abm,mmx,popcnt,tune=native")
- #define all(x) x.begin(),x.end()
- #define rall(x) x.rbegin(),x.rend()
- #define size(x) (int)x.size()
- #define f first
- #define s second
- using namespace std;
- typedef long long ll;
- typedef long double ld;
- void solve() {
- vector<vector<int>> a(4, vector<int>(7));
- int n = 28;
- vector<int> count(29, 0), bad(29, 0), sum(29, 0);
- int i, j;
- bool ch;
- int cnt;
- int ccnt;
- int t = 0;
- for(int mask = 0; mask < (1 << n); mask++) {
- ccnt = 0;
- for(i = 0; i < n; i++) {
- if(mask & (1 << i)) {
- a[i / 7][i % 7] = 1;
- ccnt++;
- }else {
- a[i / 7][i % 7] = 0;
- }
- }
- do {
- ch = false;
- for(i = 0; i < 4; i++) {
- cnt = 0;
- for(j = 0; j < 7; j++) {
- cnt += a[i][j];
- }
- if(cnt <= 2 && cnt > 0) {
- for(j = 0; j < 7; j++) {
- a[i][j] = 0;
- }
- ch = true;
- }
- }
- for(i = 0; i < 7; i++) {
- cnt = 0;
- for(j = 0; j < 4; j++) {
- cnt += a[j][i];
- }
- if(cnt == 1) {
- for(j = 0; j < 4; j++) {
- a[j][i] = 0;
- }
- ch = true;
- }
- }
- }while(ch);
- cnt = 0;
- for(i = 0; i < 4; i++) {
- for(j = 0; j < 7; j++) {
- if(a[i][j] == 1) {
- cnt++;
- }
- }
- }
- count[ccnt]++;
- sum[ccnt] += cnt;
- if(cnt > 0) {
- bad[ccnt]++;
- }
- if(t == 0) {
- cout << mask << "\n";
- }
- t++;
- if(t == 1000000) {
- t = 0;
- }
- }
- for(int i = 0; i <= 28; i++) {
- cout << "p[" << i << "] = " << ((double)bad[i]) / count[i] << ";\n";
- cout << "m[" << i << "] = " << ((double)sum[i]) / count[i] << ";\n";
- }
- }
- int main() {
- #ifndef HOME
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- // ios_base::sync_with_stdio(false);
- // cin.tie(nullptr);
- // cout.tie(nullptr);
- solve();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement