【Codeforces Round #437 (Div. 2) B】Save the problem!

【链接】h在这里写链接


【题意】


    给你一个金额N,和硬币的类型总数M;
    (完全背包),然后问你组成N的方案数.
    使得,用这些硬币组成价值为N的金额的方案数为A;
    现在A已知,让你求出一组合法的N,M以及每个硬币的面值。


【题解】


只要面值为1和面值为2。
做个完全背包。就能发现这两个能够覆盖到所有的方案数。

【错的次数】


0

【反思】


在这了写反思

【代码】

#include <bits/stdc++.h>
using namespace std;

long long bo[(int)1e6+10];
int can[(int)1e6+10];
int d[15];
map <int,int> dic;

int main()
{
    //freopen("F:\\rush.txt","r",stdin);

    bo[0] = 1;
    for (int i = 1;i <= 2;i++)
        for (int j = i;j <= (int) 1e6;j++)
            bo[j] += bo[j-i];

    int A,N,M;
    ios::sync_with_stdio(0),cin.tie(0);
    cin >> A;
    for (int i = 1;i <= (int) 1e6;i++)
        if (bo[i]==A)
        {
            cout << i <<' ';
            break;
        }
    cout << 2 << endl;
    cout <<"1 2"<<endl;
    return 0;
}


posted @ 2017-10-04 18:44  AWCXV  阅读(96)  评论(0编辑  收藏  举报