题目链接: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. iOS第三方网络图片加载- SDWebImage笔记(转)

    SDWebImage托管在github上.https://github.com/rs/SDWebImage 这个类库提供一个UIImageView类别以支持加载来自网络的远程图片.具有缓存管理.异步下 ...

  2. 【Luogu】P3628特别行动队(斜率优化DP)

    题目链接 设c[i]是战斗力前缀和,f[i]是考虑前i个,且最后一组分到第i个士兵为止的战斗力之和 则有朴素状态转移方程 ;i<=n;++i) ;j<i;++j){ int x=c[i]- ...

  3. maven配置中国下载源【转:http://www.cnblogs.com/libingbin/p/5949483.html】

    修改 配置文件 maven 安装 路径 F:\apache-maven-3.3.9\conf 修改 settings.xml或者在.m2文件夹下新建一个settings.xml 阿里源 <mir ...

  4. Linux(12):期中架构(4)--- 前端部分:HTTP & Nginx & LNMP架构

    HTTP协议概念原理说明 1. 当用户访问一个网站时经历的过程 # ①. 利用DNS服务,将输入的域名解析为相应的IP地址 a 本地主机输入域名后,会查询本地缓存信息和本地hosts b 本地主机会向 ...

  5. 页面中用Context.Handler传递

       最近被WCF弄得身心疲惫.今天抽空看了一下页面传值的一些技巧.传统的cookie session 什么的就不介绍了 今天介绍Context的用法 首先要应用using System.Runtim ...

  6. spring 容器bean

    bean配置信息----> 读取bean的配置信息到bean的注册表中---> 根据注册表的信息实例化bean---> 将bean的实例放到spring的容器中---> 应用程 ...

  7. Yii 之视图

    控制器方法代码: public function actionIndex(){ $data = array( 'name' => 'zhangsan', 'age' => 12, 'add ...

  8. Oracle ORA-01033: ORACLE initialization or shutdown in progress

    先说明,我出现此错误的原因是:我手动通过drop语句删除表空间,结果磁盘中文件还存在,然后我手动删除了文件,重启了oracle服务,再去连接oracle时就出现了这个错误. 网上也有“连接Oracle ...

  9. Apache Beam 传 大数据杂谈

    1月10日,Apache软件基金会宣布,Apache Beam成功孵化,成为该基金会的一个新的顶级项目,基于Apache V2许可证开源. 2003年,谷歌发布了著名的大数据三篇论文,史称三驾马车:G ...

  10. 微信公众账户的开发者模式(一) 部分细节access_token的获取等

    十四老久没有写博客了,中间经历了,事业,感情的几分波折.现在终于稍微缓过来一点.又是一次从头开始,走在匆忙的路上. 好了煽情完了,直接上代码了. 基础就不说了我用的是vs2005开发的,部署在iis6 ...