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;
    }
    至少做到我努力了
  • 相关阅读:
    通过IDEA创建SpringMVC项目记录
    开发问题总结
    idea控制台乱码解决
    java获取文件是否文件夹
    oralce优化文章
    乱码踩坑记录
    oracle关于左连接失效的一些问题
    volatile关键字
    postman body formdata和xwwwformurlencoded区别
    [转][C#]ScottPlot
  • 原文地址:https://www.cnblogs.com/chensunrise/p/3730827.html
Copyright © 2011-2022 走看看