Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.4 kB
2
Indexable
Never
#include <bits/stdc++.h>

using namespace std;

int n, c, v[100005], suma, cnt;
vector<int> a;

int main(){
    
    
    ifstream fin("wind.in");
    ofstream fout("wind.out");
    
    fin>>c;
    fin>>n;
    for(int i=0; i<n; i++){
        fin>>v[i];
    }
    for(int i=1; i*i<=n; i++){
            if(n%i==0){
                cnt++;
                if(n/i!=i) cnt++;
                a.push_back(i);
            }
        }
        
    if(c==1){
        fout<<cnt-1;
    }
    if(c==2){
        long long int minnr=2100000000, ans, maxnr=-2100000000, answ=0, ras=0, max2=-2100000000, e=0, l=0, k=0;
        for(int l=0; l<a.size(); l++){
            k=a[l];
            minnr=2100000000;
            maxnr=-2100000000;
            for(int i=1; i<=n; i+=k){
                suma=0;
                for(int j=i; j<i+k; j++){
                    suma+=v[j];
                }
                if(suma<=minnr){
                    minnr=suma;
                }
                if(suma>=maxnr){
                    maxnr=suma;
                    e=i;
                    fout<<e<<endl;
                }
            }
            ans=maxnr-minnr;
            if(max2<=ans){
                max2=ans;
                ras=e;
                answ=k;
            }
        }
        fout<<answ<<" "<<ras;
    }

    return 0;
}