Untitled
unknown
plain_text
a month ago
1.3 kB
4
Indexable
Never
#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; int sodoan = 0; For(i,1,n) { if (pre[i] == t) { if(sodoan == k-1) { cout << n; break; } sodoan++; 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