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;
    }
    


  • 相关阅读:
    CSS学习笔记 糖不苦
    Servlet与HTTP介绍学习 糖不苦
    new 的原理和实现 糖不苦
    HTML学习笔记 糖不苦
    事务的概念,以及事务在JDBC编程中处理事务的步骤 糖不苦
    前端JS获取用户位置 糖不苦
    数据接口请求异常:parsererror 糖不苦
    所有CSS字体属性 糖不苦
    jQuery CSS样式方法
    jQuery效果隐藏/显示,淡入/淡出,滑动,动画
  • 原文地址:https://www.cnblogs.com/jzssuanfa/p/7246641.html
Copyright © 2011-2022 走看看