• P1164-小A点菜


     1 #include <bits/stdc++.h>
     2 #define _for(i,a,b) for(int i = (a);i < b;i ++)
     3 typedef long long ll;
     4 using namespace std;
     5 inline ll read()
     6 {
     7     ll ans = 0;
     8     char ch = getchar(), last = ' ';
     9     while(!isdigit(ch)) last = ch, ch = getchar();
    10     while(isdigit(ch)) ans = (ans << 1) + (ans << 3) + ch - '0', ch = getchar();
    11     if(last == '-') ans = -ans;
    12     return ans;
    13 }
    14 inline void write(ll x)
    15 {
    16     if(x < 0) x = -x, putchar('-');
    17     if(x >= 10) write(x / 10);
    18     putchar(x % 10 + '0');
    19 }
    20 int N,M;
    21 int a[101];
    22 int dp[10003];
    23 int main()
    24 {
    25     N = read(),M = read();
    26     _for(i,0,N)
    27         a[i] = read();
    28     memset(dp,0,sizeof(dp));
    29     dp[0] = 1;
    30     _for(i,0,N)
    31         for(int j = M;j >= 0;j --)
    32             if(j>=a[i])
    33                 dp[j] += dp[j-a[i]];
    34     write(dp[3]);
    35     return 0;
    36 }
  • 相关阅读:
    nvalid bound statement (not found)
    小程序
    maven启动项目时报错
    创建Maven项目出错
    小程序的tab标签实现效果
    C# 异步
    C#中计算时间差
    linq筛选唯一
    GMap.net控件学习记录
    nodepad++ 正则 替换
  • 原文地址:https://www.cnblogs.com/Asurudo/p/11302915.html
Copyright © 2020-2023  润新知