Codeforces Round #437 B. Save the problem!

题意:

给你一个方案数,要求你输出满足该条件的总金额,面值数,和各个面值是多少,答案有多个,随便输出一个即可。

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

思路:如果A是1,那么就用1张1元的就好;如果大于1,价格都是2*(A-1),硬币只有1和2,因为,你用(A-1)个2元0个1元,然后是(A-2)个2个1元,这样方案数就相当于A-1减到0,共A种,方法十分巧妙。

代码:
#include<iostream>
using namespace std;

int main(){
    int n;
    cin>>n;
    if(n==1){
        cout<<"1 1 1 ";
    }
    else {
        cout<<2*(n-1)<<' '<<2<<endl<<1<<' '<<2<<endl;
    }
    return 0;
}
原文地址:https://www.cnblogs.com/ljy08163268/p/7632909.html