poj1004—财务管理问题\n时间限制:1000ms,空间限制:10000k。\n\n问题描述:拉里今年毕业,终于找到了工作。他赚了很多钱,但似乎从来没有足够的钱,拉里已经决定抓住金融投资组合并解决他的融
时间: 2023-05-02 15:01:25 浏览: 417
这道题是一个财务管理问题。时间限制为1000ms,空间限制为10000k。
题目描述:拉里今年毕业,终于找到了工作。他赚了很多钱,但似乎从来没有足够的钱来购买所有他想要的东西。现在他准备抓住投资的机会,投资一些资本组合,以希望获得更好的回报。他已经决定投资一定数量的资本来建立一个资本组合。
要求输出拉里需要投资的资本组合的金额。
相关问题
用C++编写程序,实现以下问题2、题目ID Codes(POJ1146) Time Limit: 1000MS Memory Limit: 10000K 描述: It is 2084 and the year of Big Brother has finally arrived, albeit a century late. In order to exercise greater control over its citizens and thereby to counter a chronic breakdown in law and order, the Government decides on a radical measure--all citizens are to have a tiny microcomputer surgically implanted in their left wrists. This computer will contains all sorts of personal information as well as a transmitter which will allow people's movements to be logged and monitored by a central computer. (A desirable side effect of this process is that it will shorten the dole queue for plastic surgeons.) An essential component of each computer will be a unique identification code, consisting of up to 50 characters drawn from the 26 lower case letters. The set of characters for any given code is chosen somewhat haphazardly. The complicated way in which the code is imprinted into the chip makes it much easier for the manufacturer to produce codes which are rearrangements of other codes than to produce new codes with a different selection of letters. Thus, once a set of letters has been chosen all possible codes derivable from it are used before changing the set. For example, suppose it is decided that a code will contain exactly 3 occurrences of a', 2 of b' and 1 of c', then three of the allowable 60 codes under these conditions are: abaabc abaacb ababac These three codes are listed from top to bottom in alphabetic order. Among all codes generated with this set of characters, these codes appear consecutively in this order. Write a program to assist in the issuing of these identification codes. Your program will accept a sequence of no more than 50 lower case letters (which may contain repeated characters) and print the successor code if one exists or the message No Successor' if the given code is the last in the sequence for that set of characters. 输入: Input will consist of a series of lines each containing a string representing a code. The entire file will be terminated by a line consisting of a single #. 输出: Output will consist of one line for each code read containing the successor code or the words 'No Successor'. 样例输入 abaacb cbbaa # 样例输出 ababac No Successor
以下是使用C++编写的程序,可以解决该问题:
```c++
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int main()
{
char str[55];
while(cin >> str && str[0] != '#')
{
if(next_permutation(str, str + strlen(str)))
cout << str << endl;
else
cout << "No Successor" << endl;
}
return 0;
}
```
首先,我们定义了一个字符数组 `str` 来存储输入的字符串。
然后,在一个循环中不断读入字符串,直到读入单独的一个 '#' 字符为止。
对于每个字符串,我们可以使用 `next_permutation` 函数来找到它的下一个排列。如果找到了下一个排列,则输出它;否则输出 "No Successor"。
需要注意的是,我们必须将 `str` 的长度作为第二个参数传递给 `next_permutation` 函数,否则它将无法正确地处理含有重复字符的字符串。
阅读全文