답안 #72470

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
72470 2018-08-26T08:24:37 Z um..(#2163, grape, sssyyy, arpiel0610) 디스토브 (FXCUP3_dstorv) C++11
0 / 100
2 ms 484 KB
#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

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);
  ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -