/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 1ms 764.0 KiB
#2 Wrong Answer 1ms 532.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef double dl;

#define endl "\n"
#define vi vector<int>
#define mii map<int,int>
#define mci map<char,int>
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;

const int mx = 1e9+7;

void solve(){
    int n;  cin >> n;

    ll ans = 0;

    int ar[n+10];

    for(int i = 0; i < n; i++){
        cin >> ar[i];
        ans+=ar[i];
        ans%=mx;
    }

    //int gc = ar[0];

    //for(int i = 1; i < n; i++){
    //    gc = __gcd(gc, ar[i]);
   // }

    //int p = pow()

    int j = 1;

    int gc;

    for(int i = 0; i < n; i++ ){
        gc = ar[i];
        for(int k = i+1; k < n; k++){
            gc = __gcd(gc, ar[k]);
            ans = (ans * gc) % mx;
            //cout << gc << " " << ans << endl;
            int tmp = 0;
            for(int m = k+1; m-k+j <= n; m++){
                tmp += __gcd(gc, ar[m]);
                //cout << m << endl;
            }
            if(tmp!=0)ans = (ans * tmp) % mx;
            //else  {ans = (ans * gc) % mx;}
        }
        j++;
    }

    cout  << ans << endl;

}

int main()
{
    optimize();

    int t;
    cin >> t;

    while(t--)  solve();

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1105 Ohh that gcd again
Contest
LUCC Presents Kick & Code Intra LU Programming Contest
Language
C++17 (G++ 13.2.0)
Submit At
2025-09-01 07:42:33
Judged At
2025-09-01 07:42:33
Judged By
Score
0
Total Time
1ms
Peak Memory
764.0 KiB