Submission #940799

# Submission time Handle Problem Language Result Execution time Memory
940799 2024-03-07T16:11:30 Z rainboy Cookie Clicker Alpha (GCJ14_cookie) C
19 / 19
1 ms 348 KB
#include <math.h>
#include <stdio.h>

int main() {
	int t, _;

	scanf("%d", &t);
	for (_ = 1; _ <= t; _++) {
		double c, f, x, p, q, ans;
		int k, h;

		scanf("%lf%lf%lf", &c, &f, &x);
		p = (x - c) * f - c * 2, q = c * f;
		k = p < 0 ? 0 : ceil(p / q);
		ans = 0;
		for (h = 0; h < k; h++)
			ans += c / (f * h + 2);
		ans += x / (f * k + 2);
		printf("Case #%d: %.12f\n", _, ans);
	}
	return 0;
}

Compilation message

cookie.c: In function 'main':
cookie.c:7:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |  scanf("%d", &t);
      |  ^~~~~~~~~~~~~~~
cookie.c:12:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |   scanf("%lf%lf%lf", &c, &f, &x);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct