제출 #1041472

#제출 시각아이디문제언어결과실행 시간메모리
1041472vjudge1Ljetopica (COI19_ljetopica)C++17
8 / 100
1 ms348 KiB
#include <bits/stdc++.h>
using namespace std;

const int N = 1e3 + 10, mod = 1e9 + 7, inv2 = 5e8 + 4;
int n, k, ans, pw;
string s, a, b;

int main(){
    cin >> n >> k >> s >> a >> b;
    
    pw = 1;
    for (int i = a.size() - 1; i >= 0; i --){
        ans += (a[i] - '0') * pw;
        ans %= mod;

        pw *= 2;
        pw %= mod;
    }

    pw = 1;
    for (int i = b.size() - 1; i >= 0; i --){
        ans += (b[i] - '0') * pw;
        ans %= mod;

        pw *= 2;
        pw %= mod;
    }

    if (a == b){
        ans = 1ll * ans * inv2 % mod;
        cout << ans << endl;
        return 0;
    }

    cout << ans << endl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...