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;
    }
    至少做到我努力了
  • 相关阅读:
    vmware:使用.zip文件在vmware中安装操作系统
    Nodejs:Node.js模块机制小结
    vue:vue router学习小结
    axios使用思路总结
    vuex:使用思路总结
    React的keepAlive路由缓存的一种实现思路
    Echarts的一些用法
    gojs去水印的方法
    平面坐标与经纬度坐标的相互转换
    HTML5 添加水印
  • 原文地址:https://www.cnblogs.com/chensunrise/p/3730827.html
Copyright © 2011-2022 走看看