fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4.  
  5. ll n, a[105], sum;
  6. bool dp[200005];
  7.  
  8. int main(){
  9. ios_base::sync_with_stdio(0);
  10. cin.tie(0);
  11.  
  12. cin >> n;
  13.  
  14. for (ll i = 1; i <= n; i++){
  15. cin >> a[i];
  16. sum += a[i];
  17. }
  18.  
  19. if (sum % 2){
  20. cout << 0 << '\n';
  21. return 0;
  22. }
  23.  
  24. dp[0] = 1;
  25.  
  26. for (ll i = 1; i <= n; i++){
  27. for (ll j = sum / 2; j >= a[i]; j--){
  28. if (dp[j - a[i]]) dp[j] = 1;
  29. }
  30. }
  31.  
  32. if (!dp[sum / 2]){
  33. cout << 0 << '\n';
  34. return 0;
  35. }
  36.  
  37. ll ans = 1, mn = LLONG_MAX;
  38.  
  39. for (ll i = 1; i <= n; i++){
  40. ll x = a[i], cnt = 0;
  41.  
  42. while (x % 2 == 0){
  43. x /= 2;
  44. cnt++;
  45. }
  46.  
  47. if (cnt < mn){
  48. mn = cnt;
  49. ans = i;
  50. }
  51. }
  52.  
  53. cout << 1 << '\n';
  54. cout << ans << '\n';
  55.  
  56. return 0;
  57. }
  58.  
Success #stdin #stdout 0s 544KB
stdin
Standard input is empty
stdout
1
1