제출 #72470

#제출 시각아이디문제언어결과실행 시간메모리
72470um.. (#118)디스토브 (FXCUP3_dstorv)C++11
0 / 100
2 ms484 KiB
#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;
}

컴파일 시 표준 에러 (stderr) 메시지

dstorv.cpp: In function 'int main()':
dstorv.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d", &N, &r, &h);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
dstorv.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s", chk);
  ~~~~~^~~~~~~~~~~
dstorv.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &A, &B);
  ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...