Skip to content

Instantly share code, notes, and snippets.

@jeehoonkang
Created November 14, 2015 12:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeehoonkang/61a8b1e3bd5ff7f173d0 to your computer and use it in GitHub Desktop.
Save jeehoonkang/61a8b1e3bd5ff7f173d0 to your computer and use it in GitHub Desktop.
#include <cstdio>
using namespace std;
int main() {
setbuf(stdout, NULL);
int nCase;
scanf("%d", &nCase);
for (int iCase = 0; iCase < nCase; ++iCase) {
long long a, b, c;
printf("Case #%d\n", iCase + 1);
scanf("%lld %lld %lld", &a, &b, &c);
while (c-- > 0) {
long long n, k;
scanf("%lld %lld", &n, &k);
long long t = a * k + b;
long long u = b * k + a;
long long x = n / t;
long long y = n % t;
if (y <= a && x * (t - u) < y) {
printf("b");
} else {
printf("a");
}
}
printf("\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment