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;
    }
  • 相关阅读:
    jsp 认知(2)
    jsp 认知
    Java 匿名类
    Usage of readonly and const
    Javascript 原型继承(续)—从函数到构造器的角色转换
    JavaScript 原型继承开端
    JS 函数调用
    Javascript Basic Operation Extraction
    JS单词形式的运算符
    git问题收集
  • 原文地址:https://www.cnblogs.com/lipoicyclic/p/13290212.html
Copyright © 2011-2022 走看看