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>
long long mul(long long a, long long b, long long m){
long long ret = 0;
while (b) {
ret += a * (b & 1023);
b >>= 10;
a <<= 10;
ret %= m;
a %= m;
}
return ret;
}
long long pw(int a, int x, long long m){
long long r = a, p = 10;
while (x) {
if(x&1) r = mul(r,p,m*10);
p = mul(p,p,m*10);
x >>= 1;
}
return r;
}
int main(){
int a,b,s,e;
scanf("%d %d %d %d",&a,&b,&s,&e);
a %= b;
long long t = pw(a,s,b);
for (int i=s; i<=e; i++) {
putchar(t/b + '0');
t %= b;
t *= 10;
}
}
# | 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... |