#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 = 0; i <= n; i++){
can[i]=0;
}
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
271 ms |
600 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2037 ms |
600 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2053 ms |
604 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |