题目链接: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("\n");
printf("%d",c2[1]);
for(int i = 2; i <= m; i++)
{
printf(" %d",c2[i]);
}
printf("\n");
}
return 0;
}

URAL 1731. Dill(数学啊 )的更多相关文章

  1. URAL 1876 Centipede's Morning(数学)

    A centipede has 40 left feet and 40 right feet. It keeps a left slippers and b right slippers under ...

  2. URAL 1820. Ural Steaks(数学啊 )

    题目链接:space=1&num=1820" target="_blank">http://acm.timus.ru/problem.aspx? space ...

  3. ural 2029 Towers of Hanoi Strike Back (数学找规律)

    ural 2029 Towers of Hanoi Strike Back 链接:http://acm.timus.ru/problem.aspx?space=1&num=2029 题意:汉诺 ...

  4. ural 2032 Conspiracy Theory and Rebranding (数学水题)

    ural 2032  Conspiracy Theory and Rebranding 链接:http://acm.timus.ru/problem.aspx?space=1&num=2032 ...

  5. URAL 1161 Stripies(数学+贪心)

    Our chemical biologists have invented a new very useful form of life called stripies (in fact, they ...

  6. URAL 2067 Friends and Berries (推理,数学)

    题意:给定 n 个人,每个人两个值s, r,要满足,p(v, u) = sqrt((sv − su)^2 + (rv − ru)^2), p(v,u,w) = (p(v,u) + p(v,w) + p ...

  7. URAL 1725. Sold Out!(数学啊 )

    题目链接:space=1&num=1725" target="_blank">http://acm.timus.ru/problem.aspx?space= ...

  8. URAL 1727. Znaika&#39;s Magic Numbers(数学 vector)

    主题链接:http://acm.timus.ru/problem.aspx?space=1&num=1727 1727. Znaika's Magic Numbers Time limit: ...

  9. URAL 1962 In Chinese Restaurant 数学

    In Chinese Restaurant 题目连接: http://acm.hust.edu.cn/vjudge/contest/123332#problem/B Description When ...

随机推荐

  1. BZOJ 4516 [Sdoi2016]生成魔咒 ——后缀自动机

    本质不同的字串,考虑SA的做法,比较弱,貌似不会. 好吧,只好用SAM了,由于后缀自动机的状态最简的性质, 所有不同的字串就是∑l[i]-l[fa[i]], 然后后缀自动机是可以在线的,然后维护一下就 ...

  2. BZOJ1221 [HNOI2001] 软件开发 【费用流】

    题目 某软件公司正在规划一项n天的软件开发计划,根据开发计划第i天需要ni个软件开发人员,为了提高软件开发人员的效率,公司给软件人员提供了很多的服务,其中一项服务就是要为每个开发人员每天提供一块消毒毛 ...

  3. [NOI2001] 食物链 (扩展域并查集)

    题目描述 动物王国中有三类动物 A,B,C,这三类动物的食物链构成了有趣的环形.A 吃 B,B 吃 C,C 吃 A. 现有 N 个动物,以 1 - N 编号.每个动物都是 A,B,C 中的一种,但是我 ...

  4. 转载:shell中awk printf的用法

    转载:http://www.linuxawk.com/jiaocheng/83.html 6. printf函数   打印输出时,可能需要指定字段间的空格数,从而把列排整齐.在print函数中使用制表 ...

  5. 【Codeforces Round #502 (Div. 1 + Div. 2) 】

    A:https://www.cnblogs.com/myx12345/p/9843032.html B:https://www.cnblogs.com/myx12345/p/9843050.html ...

  6. net3:Button的CommandName使用,AdRotator,BulletedList的使用

    原文发布时间为:2008-07-29 -- 来源于本人的百度文章 [由搬家工具导入] using System;using System.Data;using System.Configuration ...

  7. Day 8 Linux之Day8

    Linux 之 Day 8 一.Linux网络原理及基础设置 1. 使用ifconfig命令来维护网络 1) ifconfig命令的功能:显示所有正在启动的网卡的详细信息或设定系统中网卡的IP地址. ...

  8. android:logo

    <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="ht ...

  9. CSS 选择器语法参考手册

    转自:http://www.w3school.com.cn/cssref/css_selectors.asp CSS3 选择器 在 CSS 中,选择器是一种模式,用于选择需要添加样式的元素. &quo ...

  10. pandaboard串口通信调试

    1.在PC上的pyserial程序,到pandaboard后报错,读取和写入会报错 2.使用的是pandaboard的ttyO2串口 3.ls -l /dev/ttyO2,发现是tty,而不是dial ...