题目链接: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. 浅谈中途相遇攻击--meet-in-the-middle attack

    貌似挖的坑也够多了....好多都没填,这篇最后会不会TJ还得看心情TUT 看过大白书的人应该都会发现一种神奇的算法:中途相遇法.(在第58页)这种算法将以空间换时间的思路运用到了极致,但事实上它在密码 ...

  2. 【BZOJ2049】洞穴勘测(LCT)

    题意:一张图,要求支持以下操作: 1.加边 2.删边 3.询问两点之间是否联通 100%的数据满足n≤10000, m≤200000 思路:LCT裸题,不需要维护任何信息 ..,..]of longi ...

  3. Redis命令行之List

    一.Redis之List简介 1. List是简单的字符串列表,按照插入顺序排列. 2. 一个列表最多可存储232-1个元素(40多亿). 二.Redis之List命令行操作 Lrange:获取列表指 ...

  4. 用CSS3变形创建半圆形导航

    http://www.xuanfengge.com/create-a-semicircle-with-css3-variant-navigation.html demo:http://tympanus ...

  5. Executors

    提供了工厂方法: Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, Thread ...

  6. Maven配置将war包部署到Tomcat(tomcat7-maven-plugin)

    Tomcat7/8: 提示:经过测试Tomcat7的配置和插件在Tomcat8中能正常运行 tomcat7-maven-plugin官方帮助文档:http://tomcat.apache.org/ma ...

  7. [vxlan] 二 什么是VXLAN

    VXLAN是一种mac in UDP的技术.简单讲就是传统的二层帧被封装到了UDP的package中.通过UDP的IP网络发送到目的地然后再解封装. VXLAN 跟VLAN对比,最重要的一个概念就是V ...

  8. 什么场景应该用 MongoDB ?

    摘要: 月初在云栖社区上发起了一个 MongoDB 使用场景及运维管理问题交流探讨 的技术话题,有近5000人关注了该话题讨论,这里就 MongoDB 的使用场景做个简单的总结,谈谈什么场景该用 Mo ...

  9. zabbix之Low-level discovery(自动发现)

    功能: 自动发现挂载点并自动监控 自动发现网卡并自动监控 创建自动发现挂载点并监控 功能 假如要在monitor_linux模板中创建自动发现挂载点的功能 配置-->模板-->选择模板-- ...

  10. php-cpp用来开发php的拓展

    官网: http://www.php-cpp.com/documentation/install, 找时间要学一下.