2021-3月22日
2nd——1
A-Save the problem
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
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
Input will consist of a single integer A (1 ≤ A ≤ 105), the desired number of ways.
Output
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.
Examples
input
18
output
30 4
1 5 10 25
input
3
output
20 2
5 2
input
314
output
183 4
6 5 2 139
题目大义:通常情况下购物时将一定面额的现金会以不同面额的零钱的方式找回给人们,假设找回的两种方案里至少有一种面额的硬币数量不同,就可以将这两种不同面额的钞票视作不同的找零方案。
正常情况是题目会给出需找回的面额n和m种零钱的面额与种类以求得方案数a,本题则是采取逆向思维,给出所有的方案数给出的m个数的有a种方式组成面额n。
一切数额的都可以用1和2来构成,所以我们用1和2来构成面额即可,接下来是寻找规律
正向规律很容易看出来:
1 1-——一种
2 1 1; 2——两种
3 1 1 1;1 2——三种
4 1 1 1 1;1 1 2;2 2——三种
5 1 1 1 1 1; 1 1 1 2;1 2 2——三种
6 1 1 1 1 1 1;1 1 1 1 2;1 1 2 2; 2 2 2——四种
7 1 1 1 1 1 1 1 ;1 1 1 1 1 2;1 1 1 2 2;1 2 2 2——四种
…
n(n!=1) …——n/2+1种
这里要注意,从上边我们能看出来总结的规律在面额为一时是不符合总结规律的,因而要对面额为一时进行特殊处理。a=n/2+1反之可推n=2*(a-1)即可得出面额。很巧妙的思维题,不要被样例限制住思维尝试一下写出来数据。
代码如下
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
int n;
scanf("%d",&n);
if(n==1)//对n=1时的情况进行特殊处理
puts("1 1\n1");//这里n1不是什么符号是换行符后边跟了数字1,为了不产生空格才紧挨
else
printf("%d 2\n1 2",2*(n-1));
return 0;
}
有错误或者更好的思路欢迎指正 :D