# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
72046 | Semteo For Ajou (#118) | Dstorv (FXCUP3_dstorv) | C++17 | 2 ms | 360 KiB |
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 <stdio.h>
char inp[5000];
unsigned long long GCD(unsigned long long p, unsigned long long q) {
unsigned long long mo;
while (q != 0) {
mo = p % q;
p = q;
q = mo;
}
return p;
}
int main()
{
int n, r, h, A, B, i, cnta, cntb;
unsigned long long p, q, t, k;
scanf("%d %d %d", &n, &r, &h);
scanf("%s", inp);
scanf("%d %d", &A, &B);
cnta = cntb = 0;
for (i = 0; i < n; i++) {
if (inp[i] == 'R') cnta++;
else if (inp[i] == 'H') cntb++;
}
cnta = cnta - A;
cntb = cntb - B;
p = q = 1;
for (i = 1; i <= cnta; i++) {
t=GCD(r, r + h);
p = p * (r / t);
q = q * ((r + h) / t);
t = GCD(p, q);
p = p / t;
q = q / t;
}
for (i = 1; i <= cntb; i++) {
t = GCD(h, r + h);
p = p * (h / t);
q = q * ((r + h) / t);
t = GCD(p, q);
p = p / t;
q = q / t;
}
k = 1000000007 + p;
t = GCD(k, q);
k = k / t;
q = q / t;
printf("%lld", k*q);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |