Submission #1085802

#TimeUsernameProblemLanguageResultExecution timeMemory
1085802marKpart (eJOI21_kpart)C++14
0 / 100
2054 ms604 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...