Submission #72110

# Submission time Handle Problem Language Result Execution time Memory
72110 2018-08-26T05:19:47 Z Semteo For Ajou(#2257, tph00300, txepahs, bmw) Dstorv (FXCUP3_dstorv) C++17
0 / 100
2 ms 484 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, cnta, cntb, i;
	unsigned long long p, q, t, ans;
	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;
	}
	ans = 1;
	while (((1000000007 * ans + p) / q) < 1000000007) {
		if(((1000000007 * ans + p) % q) == 0) break;
		ans++;
	}
	printf("%lld\n", (1000000007 * ans + p) / 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);
  ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 484 KB Execution killed with signal 8 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -