#pragma GCC optimize("O3")
#pragma GCC target("avx,avx2")
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <bitset>
#include <cstring>
using namespace std;
typedef long long ll;
bitset<1000007>bs;
int main(){
ll t;
cin >> t;
while(t--){
ll n;
cin >> n;
vector<ll>a(n);
for(int i = 0; i < n; i++)
cin >> a[i];
vector<ll>can(n + 1);
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;
}
/*
3 1
3 4 5
1 2 90
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
268 ms |
648 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2070 ms |
652 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2023 ms |
596 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |