Garlic Blue Bridge cup simulator 5 combination number

Source: Internet
Author: User

Problem Description:
The right-hand code is to combine 6 integers in any order to calculate the maximum number that can be combined.
For example: The 4123,25,66 combination is 66412325.
Please read the program completion code to achieve this function

Code:

#include <stdio.h>
Long long max (long long x, long long y) {
    return x > Y x:y;
}
Long long test (int a[], int n) {
    long long ret = 0;
    for (int i = 0; i < n; ++i) {
        int tp = A[i];
        int j = 1;
        while (TP) {
            J *=;
            TP/=;
        }
        RET = ret * j + a[i];
    }
    return ret;
}

Long long f (int a[], int k) {
    if (k = = 6) {
        return Test (A, k);
    }
    Long long ret = 0;
    for (int i = k; i < 6; ++i) {
        int t = a[k];
        A[K] = A[i];
        A[i] = t;
        RET = max (ret,  /* Fill in the necessary code here */);//Fill in F (a,k+1)
        t = a[k];
        A[K] = A[i];
        A[i] = t;
    }
    return ret;
}

int main () {
    int a[6] = {517, 283, 429, N, 6566, +};
    printf ("%lld\n", f (A, 0));
    return 0;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.