/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 0ms 284.0 KiB
#2 Wrong Answer 2ms 284.0 KiB
#3 Wrong Answer 2ms 516.0 KiB

Code

#include<stdio.h>
#include<stdlib.h>

int main() {
    int n;
    scanf("%d", &n);

    int ar[n], res[n], i;
    for(i=0; i<n; i++) {
        scanf("%d", &ar[i]);
    }

    for(i=0; i<n; i++) {
        res[i] = 0;
    }

    for(i=1; i<=n; i++) {
        int max = 0;
        for(int j=0; j<(1<<n); j++) {
            int count = 0, neg = -1;
            for(int k=0; k<n; k++) {
                if((j>>k) & 1) {
                    count++;
                    if(neg == -1) {
                        neg = ar[k];
                    }
                    else {
                        int a = neg, b = ar[k];
                        while(b != 0) {
                            int temp = b;
                            b = a % b;
                            a = temp;
                        }
                        neg = a;
                    }
                }
            }
            if(count == i) {
                if(neg > max) max = neg;
            }
        }
        res[i-1] = max;
    }

    for(i=0; i<n; i++) {
        printf("%d ", res[i]);
    }
    printf("\n");

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1151 Max gcd group
Contest
Happy New Year 2025
Language
C++17 (G++ 13.2.0)
Submit At
2025-01-02 15:55:11
Judged At
2025-01-02 15:55:11
Judged By
Score
0
Total Time
2ms
Peak Memory
516.0 KiB