• hust 1471 Tobor and Numbers


    题目描述 

    After the hard tasks, It’s the easy time for Y.G.Tobor and Y.D.I.

    Isha is a friend of Y.D.I, as he thinks Tobor is smart too, he give Tobor a problem. This problem can describe as follow:

    Tell N continuous numbers, where these N numbers are integers in the range of [-1000,1000], and the sum of these N numbers is zero.

    Note:Two numbers are considered continuous iff the absolute value of difference between these two numbers is only 1.

    Tobor is so smart that she solve this problem in just 10 days, and how goes on you?

    输入

    There are multiple cases, you need process to EOF.

    Every line contains an integer N which is an even number in the range of (0, 50000000]

    输出

    Print case number first. Print “Yes” and these N numbers if these numbers are exits, print “No” otherwise. No blank lines between cases. See Sample Output.

    The totally output size is always less than 512Kb.

    样例输入

    8
    2
    

    样例输出

    Case 1:
    Yes
    1 2 1 0 -1 -2 -1 0
    Case 2:
    No

    这个题目把我给弄晕了,一开始没注意题目的数据范围为[-1000,1000],直接写了一个,WA了,不知道为什么,唉!再看题目是发现不对,真是活该啊
    #include<iostream>
    #include<cstdio>
    using namespace std;
    int main()
    {
        int k,n,t=0;
        while (scanf("%d",&n)!=EOF)
        {
            t++; printf("Case %d:
    ",t);
            if (n%4==0)
            {
                printf("Yes
    ");
                printf("0 1 0 -1");
                for (int i=2;i<=n/4;i++) printf(" 0 1 0 -1");
                printf("
    ");
            }
            else printf("No
    ");
        }
        return 0;
    }
    至少做到我努力了
  • 相关阅读:
    标准差、方差、协方差的简单说明
    样本的均值和方差的无偏估计
    Network In Network——卷积神经网络的革新
    Rethinking the inception architecture for computer vision的 paper 相关知识
    VIM的自动补全
    substitute 命令与 global 命令
    两个月全马训练参照表
    初跑者秘诀
    python3入门教程
    使用Python3.x抓取58同城(南京站)的演出票的信息
  • 原文地址:https://www.cnblogs.com/chensunrise/p/3730827.html
Copyright © 2020-2023  润新知