题目: 给出一串表示矩阵相乘的字符串,问这字符串中的矩阵相乘中所有元素相乘的次数。 思路: 遍历字符串遇到字母将其表示的矩阵压入栈中,遇到‘)’就将栈中的两个矩阵弹出来,然后计算这两个矩阵的元素相乘的次数,累加就可以了。 PS:注意弹出的矩阵表示的先后顺序。 代码: ...
分类:
其他好文 时间:
2019-02-28 01:03:29
阅读次数:
135
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2925 题意 n个节点,每个节点都有完全相同的n项服务。 每次可以选择一个节点,破坏该节点和相邻节点 ...
分类:
其他好文 时间:
2019-02-25 23:14:41
阅读次数:
199
Write a program that finds and displays all pairs of 5-digit numbers that between them use the digits 0 through 9 once each, such that the first numbe ...
分类:
其他好文 时间:
2019-02-25 23:10:32
阅读次数:
209
题意:在正整数集合中每次选2个数相加,加n-1次,加后把结果放入集合,把两个数除去,输出每次加的总和; 思路:用优先队列存集合,greater是小顶堆,每次取出最小的两个数就行了。 ...
分类:
其他好文 时间:
2019-02-25 14:53:48
阅读次数:
127
有n n小于等于五千 个数的集合s 每次可以从s中删除两个数 然后把他们的和放回集合 直到剩下一个数 每次操作的开销等于删除两个数二之和 求最小总开销 思路:就是每次取最小的两个数即可 用优先级队列 递增:priority_queue<int,vector<int>,greater<int> >q; ...
分类:
其他好文 时间:
2019-02-25 13:46:15
阅读次数:
177
https://vjudge.net/problem/UVA-127 题目 把52张纸牌从左到右排好,每张牌自成一个牌堆(pile)。当某张牌与它左边那张牌或者左边第三张牌“match”(花色suit或者点数mark相同)时,就把这张牌移到那张牌上面。移动之后还要查看是否可以进行其他移动。只有位于牌 ...
分类:
其他好文 时间:
2019-02-24 22:55:07
阅读次数:
214
Description Larry is very bad at math he usually uses a calculator, which worked well throughout college. Unforunately, he is now struck in a deserted ...
分类:
其他好文 时间:
2019-02-23 01:19:20
阅读次数:
170
Description A pair of numbers has a unique LCM but a single number can be the LCM of more than one possible pairs. For example 12 is the LCM of (1, 12 ...
分类:
其他好文 时间:
2019-02-23 01:11:16
阅读次数:
157
对给定的数n,求出m的最大幂次,使得m的该幂次可以整除n!。 ...
分类:
其他好文 时间:
2019-02-23 01:10:17
阅读次数:
206