zoukankan      html  css  js  c++  java
  • Codeforces Round #655 (Div. 2) A. Omkar and Completion(构造)

    You have been blessed as a child of Omkar. To express your gratitude, please solve this problem for Omkar!

    An array aa of length nn is called complete if all elements are positive and don't exceed 10001000 , and for all indices xx ,yy ,zz (1≤x,y,zn1≤x,y,z≤n ), ax+ayazax+ay≠az (not necessarily distinct).

    You are given one integer nn . Please find any complete array of length nn . It is guaranteed that under given constraints such array exists.

    Input

    Each test contains multiple test cases. The first line contains tt (1≤t≤10001≤t≤1000 )  — the number of test cases. Description of the test cases follows.

    The only line of each test case contains one integer nn (1≤n≤10001≤n≤1000 ).

    It is guaranteed that the sum of nn over all test cases does not exceed 10001000 .

    Output

    For each test case, print a complete array on a single line. All elements have to be integers between 11 and 10001000 and for all indices xx ,yy ,zz (1≤x,y,zn1≤x,y,z≤n ) (not necessarily distinct), ax+ayazax+ay≠az must hold.

    If multiple solutions exist, you may print any.

    Example

    Input

    Copy

    2

    5

    4

    Output

    Copy

    1 5 3 77 12

    384 384 44 44

    构造一下,1 3 1 3 1 3…这样即可。

    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        int t;
        cin >> t;
        while(t--)
        {
            int n;
            cin >> n;
            for(int i = 1; i <= n; i++)
            {
                if(i & 1) cout << 1 << ' ';
                else cout << 3 << ' ';
            }
            cout << endl;
        }
        return 0;
    }
  • 相关阅读:
    代码守恒定律
    第一个Dockerfile
    服务器项目白名单设置
    TOMCAT禁用不安全请求方式
    标准单例模式
    二进制,八进制,十进制,十六进制!!!!
    JAVA按层级遍历二叉树
    String的+
    安装 Rational Rose 启动报错:无法启动此程序,因为计算机中丢失 suite objects.dll
    java中文乱码问题
  • 原文地址:https://www.cnblogs.com/lipoicyclic/p/13290212.html
Copyright © 2011-2022 走看看