Wrong Answer
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=0;
for(int k=0;k<n;k++){
if((j>>k)&1){
count++;
if(neg==0){
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-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:52:38
- Judged At
- 2025-01-02 15:52:38
- Judged By
- Score
- 0
- Total Time
- 2ms
- Peak Memory
- 368.0 KiB