Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Слава Україні, Героям слава
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- string a, b;
- cin >> a >> b;
- int n = a.size(), m = b.size();
- int cnt = 0;
- for(int i = 0; i < n; i++) {
- cnt += a[i] == '*';
- }
- for(int i = 0; i < m; i++) {
- cnt += b[i] == '*';
- }
- for(int msk = 0; msk < (1 << cnt); msk++) {
- int cur = msk;
- string cura = a;
- for(auto &e : cura) {
- if(e == '*') {
- e = '0' + (cur & 1);
- cur >>= 1;
- }
- }
- long long mod = 0, pt = 1;
- for(int i = m - 1; i >= 0; i--) {
- if(b[i] == '*') {
- mod += pt * (cur & 1);
- cur >>= 1;
- } else {
- mod += pt * (b[i] == '1');
- }
- pt *= 2;
- }
- pt = 1;
- long long ans = 0;
- for(int i = n - 1; i >= 0; i--) {
- ans = (ans + pt * (cura[i] == '1')) % mod;
- pt = (pt * 2) % mod;
- }
- if(ans == 0) {
- cout << cura << "\n";
- break;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement