#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#define MOD 1000000007
using namespace std;
long long int a;
int n, pom, eee;
vector<int> e[1000100];
string s, eeee;
//*************************************************************
int main()
{
	ios_base::sync_with_stdio(0);
	getline(cin, eeee);
	for(int i=0; i<eeee.size(); i++)
	{
        n*=10;
        n+=eeee[i]-'0';
	}
	getline(cin, s);
	//cout << s << endl;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == 'x')
		{
			bool neg;
			if (i - 1 >= 0 && s[i - 1] == '~')
				neg = true;
			else
				neg = false;
			int ee = i + 1, liczba = 0;
			while (s[ee] >= '0' && s[ee] <= '9')
			{
				liczba *= 10;
				liczba += s[ee] - '0';
				ee++;
			}
			if(neg)
				e[pom].push_back(-1*liczba);
			else
				e[pom].push_back(liczba);
		}
		else if (s[i] == '^')
			pom++;
	}
	for (long long int i = 0; i < (1 << n); i++)
	{
		int wynik = 1, w;
		for (int j = 0; j <= pom; j++)
		{
			w = 0;
			for (int k = 0; k < e[j].size(); k++)
			{
				int o;
				bool p;
				bool spr;
				o = e[j][k];
				if (o < 0)
					spr = true,
					o = -1 * e[j][k];
				else
					spr = false;
				if ((i&(1 << o-1)) > 0)
					p = 1;
				else
					p = 0;
				if (spr)
					w = (w | !p);
				else
					w = (w | p);
			}
			wynik = (wynik & w);
			//cout << "w: " << w << endl;
		}
		if (wynik == 1)
			eee++;
		eee = eee % MOD;
		//cout << wynik << " " << i << endl;
	}
	cout << eee << endl;
}
        | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | #include <iostream> #include <cstdio> #include <vector> #include <string> #define MOD 1000000007 using namespace std; long long int a; int n, pom, eee; vector<int> e[1000100]; string s, eeee; //************************************************************* int main() { ios_base::sync_with_stdio(0); getline(cin, eeee); for(int i=0; i<eeee.size(); i++) { n*=10; n+=eeee[i]-'0'; } getline(cin, s); //cout << s << endl; for (int i = 0; i < s.size(); i++) { if (s[i] == 'x') { bool neg; if (i - 1 >= 0 && s[i - 1] == '~') neg = true; else neg = false; int ee = i + 1, liczba = 0; while (s[ee] >= '0' && s[ee] <= '9') { liczba *= 10; liczba += s[ee] - '0'; ee++; } if(neg) e[pom].push_back(-1*liczba); else e[pom].push_back(liczba); } else if (s[i] == '^') pom++; } for (long long int i = 0; i < (1 << n); i++) { int wynik = 1, w; for (int j = 0; j <= pom; j++) { w = 0; for (int k = 0; k < e[j].size(); k++) { int o; bool p; bool spr; o = e[j][k]; if (o < 0) spr = true, o = -1 * e[j][k]; else spr = false; if ((i&(1 << o-1)) > 0) p = 1; else p = 0; if (spr) w = (w | !p); else w = (w | p); } wynik = (wynik & w); //cout << "w: " << w << endl; } if (wynik == 1) eee++; eee = eee % MOD; //cout << wynik << " " << i << endl; } cout << eee << endl; } | 
 
            
         English
                    English