This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000009;
typedef long long ll;
bitset<maxn>bs;
int a[maxn];
int can[maxn];
int main(){
ll t; cin >> t;
while(t--){
ll n; cin >> n;
for(int i=0; i<n; i++) cin>>a[i];
for(int i = 2; i <= n; i++){
if(can[i])continue;
bool ok = false;
for(int j = 0; j+i-1<n; j++){
bs = 0;
bs[a[j]] = 1;
ll sum = a[j];
for(int k=j+1; k<j+i; k++){
bs|=(bs << a[k]);
sum += a[k];
}
if(sum % 2 == 0 && (bs[sum/2]))continue;
ok = true;
break;
}
if(!ok){
can[i] = 1;
for(int j = i; j <= n; j += i) can[j] = 1;
}
}
vector<ll>ans;
for(int i = 2; i <= n; i++) {
if(can[i])ans.push_back(i);
}
cout << ans.size()<<" ";
for(auto i: ans) cout<<i<<" ";
cout<<endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |