/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 0ms 284.0 KiB
#2 Wrong Answer 2ms 284.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 = 0; 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 temp = ar[k];
                        while(temp != 0) {
                            int rem = neg % temp;
                            neg = temp;
                            temp = rem;
                        }
                    }
                }
            }
            if(count == i) {
                if(neg > max) max = neg;
            }
        }
        res[i] = 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:49:50
Judged At
2025-01-02 15:49:50
Judged By
Score
0
Total Time
2ms
Peak Memory
284.0 KiB