Codeforces Round #437 (Div. 2, based on MemSQL Start[c]UP 3.0 - Round 2) B.Save the Problem!

B.Save the problem!

Problem statement

    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

Example 1
input
18
output
30 4
1 5 10 25
Example 2
input
3
output
20 2
5 2
Example 3
input
314
output
183 4
6 5 2 139

题意

给你一个正整数表示付钱的方案数,让你构造出一种方案,包括需付钱数和钱币种数和每种钱币面值(每种钱币都是若干多张),使得它的付钱方案数等于输入的数。

思路

这题刚看样例感觉非常不清真,其实是一道脑筋急转弯,只用去考虑两种硬币,一分和二分的,这样,我们不难想到当方案数为n时,可以构造出需付钱数为(n-1)*2,而只有两种钱币,一分和二分,问题就解决了,不过注意,要特判n等于1的情况。

Code

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline void readInt(int &x) {
    x=0;int f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    x*=f;
}
inline void readLong(ll &x) {
    x=0;int f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    x*=f;
}
/*================Header Template==============*/
int n;
int main() {
    readInt(n);
    if(n==1) {
        cout<<1<<" "<<1<<endl;
        cout<<1<<endl;
        return 0;
    }
    cout<<(n-1)*2<<" "<<2<<endl;
    cout<<1<<" "<<2<<endl;
    return 0;
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值