Sort by

recency

|

494 Discussions

|

  • + 0 comments

    In the world of www, there are countless blogs. But believe me, this blog has all the perfection that makes it unique in all. I will be back again and again.api288

  • + 0 comments

    This is exactly likewise a terrific print which we honestly dearly loved looking through. It's not actually day by day that we include the risk to figure out an item. salons in corvallis

  • + 0 comments

    That is certainly on top of that a superb send i always basically liked mastering. It may not be everyday that any of us store the chance to determine the one thing. land freight services

  • + 0 comments

    Because of this it will be significantly better which you could suitable studies just before manufacturing. You'll be able to create significantly greater guide that way. Myle v5 pods

  • + 0 comments
    #include <stdio.h>
    #include <math.h>
    #include <stdlib.h>
    
    int closest_multiple(int ab, int x) {
        int quotient = ab / x;
        int lower = quotient * x;
        int upper = (quotient + 1) * x;
        int diff_lower = abs(ab - lower);
        int diff_upper = abs(ab - upper);
        if (diff_lower < diff_upper) {
            return lower;
        } else {
            return upper;
        }
    }
    
    int main() {
        int T;
        scanf("%d", &T);
        while (T--) {
            long long a, b, x;
            scanf("%lld %lld %lld", &a, &b, &x);
            long long ab;
            if (b >= 0) {
                ab = pow(a, b);
            } else {
                ab = round(pow(a, b));
            }
            printf("%d\n", closest_multiple(ab, x));
        }    
        return 0;
    }