A—Save the problem!

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Sure, here's a C example that uses Newton-Raphson method to get fractals for f(z) = z^3 - 1 = 0: ```c #include <stdio.h> #include <math.h> #define MAX_ITER 1000 #define EPSILON 1e-6 typedef struct { double x; double y; } Complex; void newton_raphson(Complex z, Complex *z_new) { Complex numerator = {pow(z.x, 3) + 3 * z.x * pow(z.y, 2) - 1, 3 * pow(z.x, 2) * z.y - pow(z.y, 3)}; Complex denominator = {3 * pow(z.x, 2) + 3 * pow(z.y, 2), 6 * z.x * z.y}; z_new->x = z.x - numerator.x / denominator.x; z_new->y = z.y - numerator.y / denominator.y; } int main() { FILE *fp; fp = fopen("Problem1.txt", "w"); if (fp == NULL) { printf("Error opening file\n"); return 1; } for (double x = -2; x <= 2; x += 0.01) { for (double y = -2; y <= 2; y += 0.01) { Complex z = {x, y}; Complex z_new = {0, 0}; int iter = 0; while (iter < MAX_ITER) { newton_raphson(z, &z_new); double distance = sqrt(pow(z_new.x - z.x, 2) + pow(z_new.y - z.y, 2)); if (distance < EPSILON) { fprintf(fp, "%.2lf %.2lf\n", x, y); break; } z = z_new; iter++; } } } fclose(fp); return 0; } ``` This code performs a double loop over the region from -2 to 2 in both the x and y dimensions with a step size of 0.01. For each point (x, y), the code applies the Newton-Raphson method to find the root of the equation f(z) = z^3 - 1 starting from the initial point z = (x, y). The method is iterated until either the maximum number of iterations is reached (MAX_ITER) or the distance between successive iterations is below a small tolerance (EPSILON). If the root is found, the point (x, y) is considered to be part of the fractal and is written to the file "Problem1.txt" in the format "x y". Note that this code makes use of complex arithmetic and is fairly computationally intensive, so it may take a while to run depending on your machine.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值