博客
关于我
P1164 小A点菜 洛谷
阅读量:290 次
发布时间:2019-03-01

本文共 1131 字,大约阅读时间需要 3 分钟。

??????????0-1?????????????????????????????????????????????????????????????????????M?

????

  • ??????????????????????????M????????????????0-1????????
  • ??????????????????????????dp[j]?????????????????j??????????dp[0] = 1???????0?????????????????
  • ???????????a_i?????????dp?????????j??M?a_i?????dp[j] += dp[j - a_i]????????????????????????
  • ??????????????????????????????
  • ????

    #include 
    #include
    #include
    #include
    #include
    using namespace std;int main() { int n, m; while (cin >> n >> m) { int a[2000]; for (int i = 0; i < n; ++i) { cin >> a[i]; } long long dp[m + 1] = {0}; dp[0] = 1; for (int i = 0; i < n; ++i) { int current = a[i]; for (int j = m; j >= current; --j) { dp[j] += dp[j - current]; } } cout << dp[m] << endl; }}

    ????

  • ???????n?m???????n???????
  • ?????????????????m+1???dp?????0?dp[0] = 1??????0???????
  • ??dp??????????????????m????????dp????????????????
  • ?????dp[m]??????M???????????
  • ???????????????????????????????????????????

    转载地址:http://zwto.baihongyu.com/

    你可能感兴趣的文章
    OAuth2:项目演示-模拟微信授权登录京东
    查看>>
    OA系统多少钱?OA办公系统中的价格选型
    查看>>
    OA系统选型:选择好的工作流引擎
    查看>>
    OA让企业业务流程管理科学有“据”
    查看>>
    OA项目之会议通知(查询&是否参会&反馈详情)
    查看>>
    Vue.js 学习总结(13)—— Vue3 version 计数介绍
    查看>>
    OA项目之我的会议(会议排座&送审)
    查看>>
    OA项目之我的会议(查询)
    查看>>
    OA项目之我的审批(会议查询&会议签字)
    查看>>
    OA项目之项目简介&会议发布
    查看>>
    ObjC的复制操作
    查看>>
    Object c将一个double值转换为时间格式
    查看>>
    object detection之Win10配置
    查看>>
    object detection训练自己数据
    查看>>
    object detection错误Message type "object_detection.protos.SsdFeatureExtractor" has no field named "bat
    查看>>
    object detection错误之Could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR
    查看>>
    object detection错误之no module named nets
    查看>>
    Object of type 'ndarray' is not JSON serializable
    查看>>
    Object Oriented Programming in JavaScript
    查看>>
    object references an unsaved transient instance - save the transient instance before flushing
    查看>>