이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |