This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
typedef long long ll;
ll gcd(ll a, ll b) {
	return b ? gcd(b, a%b) : a;
}
ll month, md, wd;
int main() {
	int T, N;
	scanf("%d", &T);
	for (N=1; N<=T; ++N) {
		scanf("%lld%lld%lld", &month, &md, &wd);
		printf("Case #%d: ", N);
		printf("%lld\n", (month*md+wd-1)/wd+month-1 - (month-1)/(wd/gcd(wd,md)));
	}
	return 0;
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |