• 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;
    }
  • 相关阅读:
    python解析HTML的方法——HTMLParser
    使用python的nose模块进行测试
    python运行时修改代码的方法——monkey patch
    使用python的nose模块进行测试
    如何使用jquery是新tab形式
    table边框设置
    如何使用jquery是新tab形式
    table边框设置
    Notepad++安装Function list插件
    Notepad++安装Function list插件
  • 原文地址:https://www.cnblogs.com/lipoicyclic/p/13290212.html
Copyright © 2020-2023  润新知