Dollar Dayz(DP)

Description
Farmer John goes to Dollar Days at The Cow Store and discovers an unlimited number of tools on sale. During his first visit, the tools are selling variously for 1, 2, and 3.FarmerJohnhasexactly 5 to spend. He can buy 5 tools at 1eachor1toolat 3 and an additional 1 tool at $2. Of course, there are other combinations for a total of 5 different ways FJ can spend all his money on tools. Here they are:

    1 @ US$3 + 1 @ US$2 

1 @ US 3+2@US 1
1 @ US 2+3@US 1
2 @ US 2+1@US 1
5 @ US $1

Write a program than will compute the number of ways FJ can spend N dollars (1 <= N <= 1000) at The Cow Store for tools on sale with a cost of 1.. K (1 <= K <= 100).
Input
A single line with two space-separated integers: N and K.
Output
A single line with a single integer that is the number of unique ways FJ can spend his money.
Sample Input
5 3
Sample Output
5

用1到k的硬币能组成n的方法总数。

简单的dp
dp[i] = dp[i] + dp[i - k];
但是这题爆ll,手动开两个ll,一个存高位,一个存低位就好了。

#include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<utility>
#include<sstream>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int maxn = 1005;
const ll mod = 1e16;
ll dp[2][1005];
int main()
{
    #ifdef LOCAL
    freopen("C:\\Users\\ΡΡ\\Desktop\\in.txt","r",stdin);
    //freopen("C:\\Users\\ΡΡ\\Desktop\\out.txt","w",stdout);
    #endif // LOCAL
    ll n,k;
    scanf("%lld%lld",&n,&k);
    memset(dp,0,sizeof(dp));
    dp[0][0] = 1;
    for(ll i = 1;i <= k;i++)
    {
        for(ll j = i;j <= n;j++)
        {
            dp[0][j] = dp[0][j] + dp[0][j - i];
            dp[1][j] = dp[1][j] + dp[1][j - i] + dp[0][j]/mod;
            dp[0][j] = dp[0][j]%mod;
        }
    }
    if(dp[1][n])
        printf("%lld",dp[1][n]);
    printf("%lld\n",dp[0][n]);
    return 0;
}
<think>好的,我现在需要处理用户的问题:“请使用中文回答我或者给我介绍一下: dollar ls”。首先,我需要确定用户询问的具体内容。 “dollar ls”看起来像是一个命令行指令,但常见的Unix/Linux命令是“ls”,用于列出目录内容。用户可能在“ls”前加上了“dollar”符号,这可能是指命令行提示符中的$符号。通常在教程中,$符号表示普通用户权限的命令提示符,而#表示管理员权限。因此,用户可能是在问关于在命令行中使用“ls”命令时前面的$符号的含义。 接下来,我需要确认是否存在名为“dollar”的命令或与“dollar ls”相关的特定工具。经过快速回忆和搜索,没有找到名为“dollar”的标准命令行工具。因此,可能的情况是用户误解了命令提示符和命令本身的关系。 可能的解释是:当用户在终端看到类似$ ls的示例时,$符号只是提示符,实际输入的命令是“ls”。用户可能将提示符和命令混淆在一起,输入了“dollar ls”,导致系统找不到该命令。 需要进一步验证这种可能性。检查常见命令行文档,确认$符号在教程中的使用惯例。通常教程会显示$后跟命令,指示用户输入命令时不带$符号。例如: $ ls 表示用户应输入“ls”而不是“$ ls”。 因此,用户的问题可能是由于误解了命令提示符的作用,导致输入错误。此时,正确的做法是解释$符号的含义,并指导用户正确使用“ls”命令。 另外,需要排除其他可能性,比如用户是否指的是某种脚本或程序中的“dollar ls”,但考虑到常见系统环境,这种情况较为少见。如果用户确实遇到了“dollar ls”的错误信息,可能是因为在输入命令时包含了$符号,导致系统尝试执行名为“$”的命令,而后面跟着的参数“ls”会被视为参数,从而引发错误。 总结:用户的问题源于对命令行提示符$的理解有误,需要解释$的作用,并指导正确使用ls命令。</think>关于您提到的`dollar ls`,以下是逐步解释: 1. **命令行提示符的误解** 在Linux/Unix终端中,`$`符号是**普通用户的命令提示符**,仅表示系统等待输入命令,**不需要手动输入**。例如: ```bash $ ls ``` 此处用户只需输入`ls`,而非`$ ls`。若误将`$`作为命令的一部分输入,系统会提示`command not found`错误(因为系统尝试查找名为`$`的命令)。 2. **`ls`命令的作用** `ls`是**列出当前目录内容**的基础命令,常用选项包括: - `ls -l`:显示详细信息(权限、所有者、大小等) - `ls -a`:显示隐藏文件(以`.`开头的文件) - `ls /path/to/dir`:查看指定目录内容 3. **实际使用示例** 正确输入命令(忽略`$`符号): ```bash ls ``` 输出结果类似: ``` Documents Downloads Music file.txt ``` 4. **若输入`$ ls`会发生什么?** 系统会尝试执行名为`$`的命令,并传递`ls`作为参数。由于`$`不是有效命令,终端会报错: ```bash $ $ ls bash: $: command not found ``` 5. **其他提示符符号** - `#`:表示**管理员(root)权限**的提示符,例如: ```bash # apt update ``` 此时需要谨慎操作。 总结:`dollar ls`是命令行提示符`$`与命令`ls`的误组合,正确用法是直接输入`ls`。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值