CodeForces - 867B Save the problem! (构造题)

Save the problem!
题 意:给你一个方案总数n,要求你输出价格,以及多少种面值的硬币,每种面值是多少,刚好又n种方案可以凑成这个价格。
数据范围:
1<=N<=1e6
输入样例:

18

输出样例:

30 4
1 5 10 25

思 路:选用1,2去构造。如果是A等于1就直接输出1,如果是其他则价格为2*(A-1)
收获:构造题,一定要去找准关键点,只要找出一种符合题意的就可以了

#include<bits/stdc++.h>
using namespace std;
typedef long long  ll;
const int maxn = 2e2+5;
const int INF = 0x3f3f3f3f;
int n;
char s[maxn];
int main(){
    scanf("%d",&n);
    if(n == 1){
        printf("1 1\n");
        printf("1\n");
        return 0;
    }
    printf("%d %d\n",2*(n-1),2);
    printf("1 2\n");
    return 0;
}
/*
6 9 2 3
*/

猜你喜欢

转载自blog.csdn.net/qq_37129433/article/details/81711060