답안 #72046

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
72046 2018-08-26T04:57:36 Z Semteo For Ajou(#2257, tph00300, txepahs, bmw) 디스토브 (FXCUP3_dstorv) C++17
0 / 100
2 ms 360 KB
#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

dstorv.cpp: In function 'int main()':
dstorv.cpp:16: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:17:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s", inp);
  ~~~~~^~~~~~~~~~~
dstorv.cpp:18: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 360 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 -