URAL 1731. Dill(数学啊 )
题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1731
1731. Dill
Memory limit: 64 MB
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
Output
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 |
代码例如以下:
#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(数学啊 )的更多相关文章
- 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 ...
- URAL 1820. Ural Steaks(数学啊 )
题目链接:space=1&num=1820" target="_blank">http://acm.timus.ru/problem.aspx? space ...
- ural 2029 Towers of Hanoi Strike Back (数学找规律)
ural 2029 Towers of Hanoi Strike Back 链接:http://acm.timus.ru/problem.aspx?space=1&num=2029 题意:汉诺 ...
- ural 2032 Conspiracy Theory and Rebranding (数学水题)
ural 2032 Conspiracy Theory and Rebranding 链接:http://acm.timus.ru/problem.aspx?space=1&num=2032 ...
- URAL 1161 Stripies(数学+贪心)
Our chemical biologists have invented a new very useful form of life called stripies (in fact, they ...
- 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 ...
- URAL 1725. Sold Out!(数学啊 )
题目链接:space=1&num=1725" target="_blank">http://acm.timus.ru/problem.aspx?space= ...
- URAL 1727. Znaika's Magic Numbers(数学 vector)
主题链接:http://acm.timus.ru/problem.aspx?space=1&num=1727 1727. Znaika's Magic Numbers Time limit: ...
- URAL 1962 In Chinese Restaurant 数学
In Chinese Restaurant 题目连接: http://acm.hust.edu.cn/vjudge/contest/123332#problem/B Description When ...
随机推荐
- [luoguP3159] [CQOI2012]交换棋子(最小费用最大流)
传送门 好难的网络流啊,建图真的超难. 如果不告诉我是网络流的话,我估计就会写dfs了. 使用费用流解决本题,设点 $p[i][j]$ 的参与交换的次数上限为 $v[i][j]$ ,以下为建图方式: ...
- CentOS7下安装Docker-Compose No module named 'requests.packages.urllib3'
在使用Docker的时候,有一个工具叫做 docker-compose,安装它的前提是要安装pip工具. 1.首先检查Linux有没有安装Python-pip包,直接执行 yum install p ...
- 【HDOJ6222】Heron and His Triangle(Java,二分,递推)
题意:让你找这样的一个三角形,三条边为t,t-1,t+1,并且面积为整数,最后满足t大于等于n. n<=1e30 思路:直接推式子不会,打表找规律 f(n)=4*f(n-1)-f(n-2)(n& ...
- OC-为何用copy修饰block
简单来说,block就像一个函数指针,指向我们要使用的函数. 就和函数调用一样的,不管你在哪里写了这个block,只要你把它放在了内存中(通过调用存在这个block的方 法或者是函数),不管放在栈中还 ...
- (4)Swing布局
一.FlowLayout-流布局 新增第一个组件后默认在第一行的居中位置,之后 组件按照加入的先后顺序按照设置的对齐方式从左向右排列 二.borderLayout-边框布局 容器划分为东.西.南.北. ...
- Codeforces 487B Strip (ST表+线段树维护DP 或 单调队列优化DP)
题目链接 Strip 题意 把一个数列分成连续的$k$段,要求满足每一段内的元素最大值和最小值的差值不超过$s$, 同时每一段内的元素个数要大于等于$l$, 求$k$的最小值. 考虑$DP$ 设$ ...
- java 基础 5 String StringBuffer StringBuilder
String是不可变的,原因 1是可以缓存hash值,因为String的hash值经常被使用,例如String用作HashMap等.不可变特性 使得hash值不变,因此只需要进行一次计算: 2Str ...
- Java笔试面试题007
Java笔试面试题007 1.请用正則表達式匹配出QQ号(如果QQ号码为5-10位). 解答: ^ \d{5,10}$ 2.String, StringBuffer StringBuilder的差别. ...
- [WASM] Create a New Rust/Webpack Project using the rust-webpack Template
Previous to this post, we set up our own Rust/wasm project from scratch. The Rust/wasm team ships a ...
- HDU 5366:The mook jong 递推
The mook jong Accepts: 506 Submissions: 1281 Time Limit: 2000/1000 MS (Java/Others) Memory Limit ...