zoukankan      html  css  js  c++  java
  • 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;
    }
    至少做到我努力了
  • 相关阅读:
    python中__dict__和dir()
    python学习之copy模块
    python学习之optparse
    python join和split和strip用法
    浅谈 Python 的 with 语句
    Python:itertools模块
    OpenStack Swift client开发
    OpenStack Swift集群部署流程与简单使用
    python bisect模块
    Python中的导入
  • 原文地址:https://www.cnblogs.com/chensunrise/p/3730827.html
Copyright © 2011-2022 走看看