题目链接: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. SHOWMODALDIALOG表单提交时禁止打开新窗口

    前提条件:showmodaldialog中有表单form.当action="#"的时候,提交表单,不会打开新窗口,但这种#自提有时不能用,#是本页面完整的带参数的url,如果表单中 ...

  2. LinkedList的构造函数有哪些

    LinkedList构造函数有(两种): public LinkedList() public LinkedList(Collection<? extends E> c) /** * Co ...

  3. uva 11426 线性欧拉函数筛选+递推

    Problem J GCD Extreme (II) Input: Standard Input Output: Standard Output Given the value of N, you w ...

  4. net8:文本文件的创建及其读写

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

  5. Python中%r与%s的区别

    %r是rper()方法处理的对象 %s是str()方法处理的对象 其实有些情况下,两者处理的结果是一样的,比如说处理数据类型为int型对象: 例如1: print ('I am %d year old ...

  6. centos tomcat 关于日志

    一.实时查看tomcat的日志 1.先切换到tomcat5/logs 2.tail -f catalina.out 3.这样运行时就可以实时查看运行日志了 例如: cd /tomcat7/logs t ...

  7. MySQL的LOOP, LEAVE 和ITERATE语句(类似Continue、Break的写法)

    和REPEAT和while语句不同,LOOP.LEAVE.ITERATE更像其他编程语言中的goto语句. LOOP要设定一个label指定循环的开始位置,而LEAVE则像其他语言中的Break会离开 ...

  8. 详解DNS,你真的懂吗?

    what`s  this ? 概念 域名系统(英文:DomainNameSystem,缩写:DNS)是互联网的一项服务.它作为将域名和IP地址相互映射的一个分布式数据库,能够使人更方便地访问互联网.D ...

  9. UVA 111

    又被题意坑了... 输入的一串数字的含义是第i个数字是第a[i]个发生的.而不是编号为i的历史事件的实际发生顺序.所以第一步要做的是转换,将原始数据转换成编号为i的历史事件的实际发生顺序.然后按照实际 ...

  10. Raft算法详解

    一致性算法Raft详解 背景 熟悉或了解分布性系统的开发者都知道一致性算法的重要性,Paxos一致性算法从90年提出到现在已经有二十几年了,而Paxos流程太过于繁杂实现起来也比较复杂,可能也是以为过 ...