codeforces 865A Save the problem!
来源:互联网 发布:linux 显卡 编辑:程序博客网 时间:2024/05/17 09:26
Attention: we lost all the test cases for this problem, so instead of solving the problem, we need you to generate test cases. We're going to give you the answer, and you need to print a test case that produces the given answer. The original problem is in the following paragraph.
People don't use cash as often as they used to. Having a credit card solves some of the hassles of cash, such as having to receive change when you can't form the exact amount of money needed to purchase an item. Typically cashiers will give you as few coins as possible in change, but they don't have to. For example, if your change is 30 cents, a cashier could give you a 5 cent piece and a 25 cent piece, or they could give you three 10 cent pieces, or ten 1 cent pieces, two 5 cent pieces, and one 10 cent piece. Altogether there are 18 different ways to make 30 cents using only 1 cent pieces, 5 cent pieces, 10 cent pieces, and 25 cent pieces. Two ways are considered different if they contain a different number of at least one type of coin. Given the denominations of the coins and an amount of change to be made, how many different ways are there to make change?
As we mentioned before, we lost all the test cases for this problem, so we're actually going to give you the number of ways, and want you to produce a test case for which the number of ways is the given number. There could be many ways to achieve this (we guarantee there's always at least one), so you can print any, as long as it meets the constraints described below.
Input will consist of a single integer A (1 ≤ A ≤ 105), the desired number of ways.
In the first line print integers N and M (1 ≤ N ≤ 106, 1 ≤ M ≤ 10), the amount of change to be made, and the number of denominations, respectively.
Then print M integers D1, D2, ..., DM (1 ≤ Di ≤ 106), the denominations of the coins. All denominations must be distinct: for any i ≠ j we must have Di ≠ Dj.
If there are multiple tests, print any of them. You can print denominations in atbitrary order.
18
30 41 5 10 25
3
20 25 2
314
183 46 5 2 139
样例:n表示要凑出来的钱,m表示钱的币值种类,接下来一行的m个数表示m种币值的值,
若构造出来的样例可以有A种方法凑出n,则输出这组样例。
思路:用最简单的情况:
n 2
1 2
问题转化成,两种币值,分别为1、2,求是否有A种方式能凑出n,若是,输出样例,否则,继续寻找。
若n=1,则两块钱的币值取0。一种
若n=2,则两块钱的币值取0,1。两种
若n=3,则两块钱的币值取0,1。两种
若n=4,.............取0,1,2。三种
最终结果为 n/2+1 种
所以只需要判断,n/2+1是否等于A,是,输出样例,否,n++
AC代码:
#include<iostream>using namespace std;int a;int n;int main(){while(cin>>a){n=1;while(1){if(n/2+1==a){cout<<n<<" "<<2<<endl;cout<<1<<" "<<2<<endl;break;}n++;}}}
- codeforces 865A Save the problem!
- CodeForces 867B Save the problem!
- Codeforces Round #437 (Div. 2) B. Save the problem!
- Save the problem!
- Codeforces 624A Save Luke
- CodeForces 624A - Save Luke
- CodeForces 624A Save Luke
- CodeForces 624A Save Luke
- 【CodeForces】[624A]Save Luke
- A. Help Vasilisa the Wise 2 codeforces-problem-143A
- Codeforces Problem-124A. The number of positions
- Problem--266A--Codeforces--Stones on the Table
- The four boys save money's problem
- The Door Problem CodeForces
- Problem - 152A - Codeforces
- codeforces problem/244/A
- codeforces problem/415/A
- codeforces. problem/408/A
- IT人喝酒,不同岗位不同姿势
- 机器学习没有想象中的那么难
- 常见的几种最优化方法
- 蒙特卡罗方法入门
- 基础练习 回文数
- codeforces 865A Save the problem!
- I/O 模型
- 工作日志-start java-磕磕绊绊 一
- C语言和C++中const关键字使用的异同
- Android框架之路——Notification的使用
- 基于PCA和SVM的人脸识别之一.基本知识
- zookeeper 启动失败
- C++中的hash_map和map的区别
- 23种设计模式之一