This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |