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 <cstdio>
char st[200001], ed[200001];
int bn[10000001], front, rear;
int mod=19980305;
int main() {
int sp=0, se=0, ep=0, ee=0;
gets(st); gets(ed);
front = rear = 0;
bn[rear++]=0;
bool secheck, eecheck;
while(st[sp] || ed[ep]) {
secheck=false;
eecheck=false;
if( front==se ) secheck=true;
if( front==ee ) eecheck=true;
int temp = bn[front++];
if( secheck && st[sp]=='3' ) {
sp++;
se = rear;
secheck = false;
}
if( eecheck && ed[ep]=='3' ) {
ep++;
ee = rear;
eecheck = false;
}
bn[rear++] = (10*temp+3)%mod;
if( secheck && st[sp]=='5' ) {
sp++;
se = rear;
secheck = false;
}
if( eecheck && ed[ep]=='5' ) {
ep++;
ee = rear;
eecheck = false;
}
bn[rear++] = (10*temp+5)%mod;
if( secheck && st[sp]=='8' ) {
sp++;
se = rear;
secheck = false;
}
if( eecheck && ed[ep]=='8' ) {
ep++;
ee = rear;
eecheck = false;
}
bn[rear++] = (10*temp+8)%mod;
}
int ans = 0;
for(int i=se;i<ee;i++) {
ans += (int)((long long)bn[i]*bn[i+1]%mod);
ans %= mod;
}
printf("%d",ans);
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |