A. Windblume Ode

1. Problem

A bow adorned with nameless flowers that bears the earnest hopes of an equally nameless person.

You have obtained the elegant bow known as the Windblume Ode. Inscribed in the weapon is an array of nn (n≥3n≥3) positive distinct integers (i.e. different, no duplicates are allowed).

Find the largest subset (i.e. having the maximum number of elements) of this array such that its sum is a composite number. A positive integer xx is called composite if there exists a positive integer yy such that 1<y<x1<y<x and xx is divisible by yy.

If there are multiple subsets with this largest size with the composite sum, you can output any of them. It can be proven that under the constraints of the problem such a non-empty subset always exists.

Input

Each test consists of multiple test cases. The first line contains the number of test cases tt (1≤t≤1001≤t≤100). Description of the test cases follows.

The first line of each test case contains an integer nn (3≤n≤1003≤n≤100) — the length of the array.

The second line of each test case contains nn distinct integers a1,a2,…,ana1,a2,…,an (1≤ai≤2001≤ai≤200) — the elements of the array.

Output

Each test case should have two lines of output.

The first line should contain a single integer xx: the size of the largest subset with composite sum. The next line should contain xx space separated integers representing the indices of the subset of the initial array.

Example

input

4
3
8 1 2
4
6 9 4 2
9
1 2 3 4 5 6 7 8 9
3
200 199 198

output

2
2 1
4
2 1 4 3
9
6 9 1 2 3 4 5 7 8
3
1 2 3 

2. Accepted Code

#include <stdio.h>
#include <stdlib.h>

int judgeSumNum(int x);

int main()
{
    int t;
    scanf("%d", &t);
    while(t--){
        int n;
        scanf("%d", &n);
        int i;
        int arr[n], sum = 0;
        for(i=0; i<n; i++){
            scanf("%d", &arr[i]);
            sum += arr[i];
        }
        if(sum%2==0 || judgeSumNum(sum)){ // sum为偶数
            printf("%d\n", n);
            for(i=0; i<n; i++){
                printf("%d ", i+1);
            }
        }else{  //sum为奇数
            printf("%d\n", n-1);
            int flag = 0;
            for(i=0; i<n; i++){
                if(arr[i]%2==0){
                    printf("%d ", i+1);
                }else if(arr[i]!=2 && flag ==0){
                    flag++;
                    continue;
                }else{
                    printf("%d ", i+1);
                }
            }
        }
        printf("\n");
    }
    return 0;
}

int judgeSumNum(int x){  //判断是否为合数
    int i;
    for(i=2 ;i<x; i++){
        if(x%i==0)
            return 1;
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/CH_whale/article/details/120924415