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


  • 相关阅读:
    C语言宏定义##连接符和#符的使用
    C语言宏高级用法 [总结]
    101平衡模式 DIR的理解
    MACHINE_START 怎样调用
    SYSCALL_DEFINE3宏定义的分析
    ARM-Linux系统调用流程
    SYSCALL_DEFINE3 宏定义的转换
    socket编程之select()
    socket编程之select()
    Oracle 常用的查询操作
  • 原文地址:https://www.cnblogs.com/jzssuanfa/p/7246641.html
Copyright © 2011-2022 走看看