/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 3ms 1.344 MiB
#2 Accepted 4ms 1.566 MiB
#3 Accepted 8ms 1.523 MiB
#4 Accepted 8ms 1.445 MiB
#5 Accepted 8ms 3.434 MiB
#6 Accepted 8ms 3.477 MiB
#7 Accepted 7ms 2.777 MiB
#8 Accepted 9ms 3.547 MiB
#9 Accepted 11ms 3.547 MiB
#10 Accepted 18ms 3.543 MiB
#11 Accepted 141ms 5.457 MiB
#12 Wrong Answer 120ms 5.418 MiB
#13 Wrong Answer 43ms 4.82 MiB

Code

// I AM A MUSLIM

#include "bits/stdc++.h"

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

#define fastIO std::ios::sync_with_stdio(0);std::cin.tie(0)
#define ll long long int
#define flush fflush(stdout)
#define bl printf("\n")
#define yn(a, b) printf("%s\n", a >= b ? "Yes":"No")
// #define int ll

using pii = std::pair<int,int>;

const int MOD = 1000000007;
// const int MOD = 998244353;
const int mxN = 101;

int N, a[mxN], dp[mxN][mxN][mxN];
bool used[mxN][mxN][mxN];

int fn(int at, int evC, int evG, int odG) {
    if (at == N) {
        if (N&1) return ((evC+1) == (N-evC)) ? evG+odG : -100100;
        return (evC == (N-evC)) ? evG+odG : -100100;
    }
    if (used[at][evC][evG]) return dp[at][evC][evG];
    int op1 = fn(at+1, evC+1, std::__gcd(evG,a[at]), odG);
    int op2 = fn(at+1, evC, evG, std::__gcd(odG,a[at]));
    used[at][evC][evG] = 1;
    return dp[at][evC][evG] = std::max(op1, op2);
}

signed main() {
    // fastIO;
    int testCases=1;
    scanf("%d",&testCases);
    // std::cin>>testCases;
    
    for (int TC = 1; TC <= testCases; TC++) {
        scanf("%d",&N);
        for (int i = 0; i < N; i++) {
            scanf("%d",&a[i]);
        }
        memset(used,0,sizeof(used));
        printf("%d\n", fn(0,0,0,0));
        
    }
    
    return 0;
}

/*

*/

Information

Submit By
Type
Submission
Problem
P1076 Even Odd GCD (Easy Version)
Contest
Bangladesh 2.0
Language
C++20 (G++ 13.2.0)
Submit At
2024-08-16 16:14:47
Judged At
2024-11-11 03:15:26
Judged By
Score
35
Total Time
141ms
Peak Memory
5.457 MiB