B. XOR = Average


Example

Input

3
1
4
3

Output

69
13 2 8 1
7 7 7

在第一个测试案例中, 69=691=69

在第二个测试用例中, 13281=13+2+8+14=6

[!TIP]

异或的性质:a⊕a=0 ,a⊕0=a

按位异或的结果的平均值等于所有数的平均值

#include <iostream>
using namespace std;
 
int main() {
    int t;
    scanf("%d", &t);
    while (t--) {
        int n;
        scanf("%d", &n);
        if (n % 2 == 0) //奇偶
        {
            printf("%d %d ", 1, 3);
            for (int j = 0; j < n - 2; j++) {//补n-2个2
                printf("%d ", 2);
            }
        } else {
            for (int j = 0; j < n; j++) {
                printf("%d ", 1);
            }
        }
        printf("\n");
    }
    return 0;
}

posted @   土木牢盖  阅读(5)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示