URAL 1731. Dill(数学啊 )
2017-07-27 19:09
288 查看
题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1731
1731. Dill
Time limit: 0.5 secondMemory 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 ≤ n, m ≤ 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(数学啊 )
- URAL 2070. Interesting Numbers(素数打表 数学题)
- URAL 1617. Flat Spots(数学啊 )
- URAL 1161 Stripies(数学+贪心)
- 数学分析 + 容斥原理 - URAL 1907 Coffee and Buns
- URAL 1515 Cashmaster 数学题
- (组合数学3.3.2.1)URAL 1091. Tmutarakan Exams(容斥定理)
- URAL 1551. Sumo Tournament(数学啊 )
- URAL 1510. Order(map 数学啊)
- 【Ural】1066 数学题 Garland
- URAL 1823. Ideal Gas(数学啊 )
- URAL 1814 Continued Fraction 数学 矩阵乘法
- URAL 1718 . Rejudge(数学啊 )
- URAL 1613. For Fans of Statistics(STL 数学啊 )
- URAL 1120. Sum of Sequential Numbers (数学)
- URAL 1113(数学)
- URAL 1051 跳跳棋(孔明棋)(加强版) 数学找规律(较弱哦)
- URAL 1820. Ural Steaks(数学啊 )
- 数学分析 + 容斥原理 - URAL 1907 Coffee and Buns
- URAL 1295. Crazy Notions(数学啊 & 找规律)