zoukankan      html  css  js  c++  java
  • URAL 1731. Dill(数学啊 )

    题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1731



    1731. Dill

    Time limit: 0.5 second
    Memory limit: 64 MB
    Ivan Vasil'evich likes to work in his garden. Once he heard that dill was a very beautiful and healthy crop and planted his whole garden with two varieties of it.
    When the dill was ripe, Ivan Vasil'evich harvested it and put it into boxes. He filled n boxes with dill of the first variety and m boxes with dill of the second variety. The weight of each box with dill in kilograms was an integer and all the weights were different. In order to please his neighbors Ivan Ivanovich and Ivan Nikiforovich, Ivan Vasil'evich decided to give each of them two boxes with dill, one box of each variety. Ivan Vasil'evich didn't want Ivan Ivanovich and Ivan Nikiforovich to quarrel, so he decided that the total weight of the boxes given to each of the neighbors should be equal. Ivan Vasil'evich considered all the possible variants and saw that this was impossible. Find the weights of all the boxes with dill stocked by Ivan Vasil'evich.

    Input

    The only input line contains space-separated integers n and m (2 ≤ nm ≤ 50).

    Output

    In the first line output n space-separated integers. These must be the weights of the boxes with the first variety of dill. In the second line output m space-separated integers, which are the weights of the boxes with the second variety of dill. The integers must be positive, different, and should not exceed 109. If there are several solutions, output any of them. If there is no solution, output the line “It is a lie!”.

    Sample

    input output
    2 3
    1 2
    5 10 12


    代码例如以下:

    #include <cstdio>
    #include <cstring>
    #define LL __int64
    int main()
    {
        int n, m;
    
        int c1[57], c2[57];
        while(~scanf("%d%d",&n,&m))
        {
            int a = 1;
            for(int i = 1; i <= n; i++)
            {
                c1[i] = a++;
            }
            c2[1] = a;
            for(int i = 2; i <= m; i++)
            {
                c2[i] = a+c2[i-1];
            }
            printf("%d",c1[1]);
            for(int i = 2; i <= n; i++)
            {
                printf(" %d",c1[i]);
            }
            printf("
    ");
            printf("%d",c2[1]);
            for(int i = 2; i <= m; i++)
            {
                printf(" %d",c2[i]);
            }
            printf("
    ");
        }
        return 0;
    }
    


  • 相关阅读:
    yii框架入门学习笔记二 根据数据表创建model类
    mysql数据库操纵类升级版
    yii框架入门学习笔记三 完善登陆功能
    java发送http的get、post请求
    Please ensure that adb is correctly located at 'D:\androidsdkwindows\platf
    CodeIgniter框架入门教程——第一课 Hello World!
    C#正则表达式应用
    common lisp 笔记2 a cd ripper
    javascript的String函数
    修改linux下sudo设置
  • 原文地址:https://www.cnblogs.com/jzssuanfa/p/7246641.html
Copyright © 2011-2022 走看看