# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
72470 | um.. (#118) | Dstorv (FXCUP3_dstorv) | C++11 | 2 ms | 484 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>
#include <stdlib.h>
#include <string.h>
#include <math.h>
using namespace std;
int main() {
int N, r, h, A, B;
scanf("%d %d %d", &N, &r, &h);
char *chk = (char*)malloc(sizeof(char) * N);
scanf("%s", chk);
scanf("%d %d", &A, &B);
int len = strlen(chk);
int num_R = 0;
int num_H = 0;
for(int i = 0; i < len; i++){
if(chk[i] == 'R') num_R++;
else if(chk[i] == 'H') num_H++;
}
num_R -= A;//�������� ��
num_H -= B;//R�� H�� ����
long long up = pow(r, num_R) + pow(h, num_H);
long long down = pow((r + h), (num_R + num_H));
long long a = up;
long long gcd = down;
while(a != 0){
long long swap = a;
a = gcd % a;
gcd = swap;
}
up /= gcd;
down /= gcd;
long long ten_9 = pow(10, 9);
long long res;
for(int i = 1; i < 15; i++){
if((((ten_9 + 7) * i + up) % down) == 0){
res = ((ten_9 + 7) * i + up) / down;
}
}
printf("%lld\n", res);
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... |