/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 584.0 KiB
#2 Wrong Answer 1ms 540.0 KiB
#3 Wrong Answer 2ms 348.0 KiB
#4 Wrong Answer 1ms 532.0 KiB
#5 Wrong Answer 1ms 536.0 KiB
#6 Wrong Answer 2ms 576.0 KiB
#7 Wrong Answer 1ms 396.0 KiB
#8 Wrong Answer 2ms 580.0 KiB
#9 Wrong Answer 2ms 576.0 KiB
#10 Wrong Answer 3ms 580.0 KiB
#11 Wrong Answer 14ms 580.0 KiB
#12 Wrong Answer 14ms 532.0 KiB
#13 Wrong Answer 6ms 536.0 KiB
#14 Wrong Answer 6ms 444.0 KiB
#15 Wrong Answer 6ms 576.0 KiB
#16 Wrong Answer 6ms 584.0 KiB
#17 Wrong Answer 6ms 580.0 KiB
#18 Wrong Answer 7ms 576.0 KiB
#19 Wrong Answer 6ms 588.0 KiB

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];

int fn(int at, int evC, int evG, int odG) {
    if (at == N) {
        if (N&1) return (evC == (N-evC+1)) ? evG+odG : 0;
        return (evC == (N-evC)) ? evG+odG : 0;
    }
    if (dp[at][evC] != -1) return dp[at][evC];
    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]));
    return dp[at][evC] = 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(dp,-1,sizeof(dp));
        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:04:22
Judged At
2024-10-03 13:28:47
Judged By
Score
1
Total Time
14ms
Peak Memory
588.0 KiB