Untitled

mail@pastecode.io avatar
unknown
plain_text
5 months ago
1.1 kB
26
Indexable
#include <bits/stdc++.h>
#define endl '\n'
#define maxn 105
#define TASK bai1
#define For(i,a,b) for ( int i = a; i <= b; i++ )
#define Ford(i,a,b) for ( int i = a; i >= b; i-- )
#define MOD 100000000000007

using namespace std;
int a[maxn],n,tong,t,pre[maxn],td;
void inp()
{
    cin >> n;
    For(i,1,n)
    {
        cin >> a[i];
        pre[i] = pre[i-1] + a[i];
    }
    tong = pre[n];
}
bool check(int k)
{
    if(tong % k !=0) return false;
    t = td = tong / k;
    int sodoan = 0;
    For(i,1,n)
        if(pre[i] == t)
        {
            sodoan++;
            t += td;
        }
    return (sodoan>=k);
}

void print(int k)
{
    cout << k << endl;
    t = td =tong / k;
    For(i,1,n)
        if (pre[i] == t)
        {
            t += td;
            cout << i << " ";
        }
}
void solve()
{
    Ford(i,n,1)
    if(check(i))
    {
        print(i);
        break;
    }
}
int main()
{
    ios_base:: sync_with_stdio(0);
    cin.tie(0);
    if(fopen("bai7.inp","r"))
    {
        freopen("bai7.inp","r",stdin);
    }
    inp();
    solve();
    return 0;
}
Leave a Comment