比起之前一直在刷的背包题,这道题可以算是最纯粹的dp了,写下简单题解。 题意是说cows在1树和2树下来回移动取苹果,有移动次数限制,问最后能拿到的最多苹果数,含有最优子结构性质,大致的状态转移也不难想出,以 dp[i][j] 表示第 i 分钟使用了 j 次移动机会时能获得的最多苹果数(不需3...
分类:
移动开发 时间:
2015-03-05 19:25:41
阅读次数:
148
A
简单题
B
简单题
C
简单题
D
简单题
E
一棵树 给你2个点 求树上有多少个点到这两个点的距离相等
#include
#include
#include
using namespace std;
const int maxn = 100010;
int anc[maxn][20];
int fa[maxn], L[maxn], sum[maxn];...
分类:
其他好文 时间:
2015-03-04 14:41:14
阅读次数:
136
题目:给你一个10个数字组成的串s,最后一位可能是X(代表10),计算出前1~前10项的和s1,
在对s1,计算前1~前10项的和,问第10项能否被11整除,即10s(0)+9s(1)+...+s(10)。
分析:简单题。模拟即可,注意题意即可。
说明:合法的串,首尾会有若干空格,中间会有‘-’、数字、或者租后一个数字是‘X’。
#include
#include...
分类:
其他好文 时间:
2015-03-03 16:44:47
阅读次数:
289
A
简单题
B
有m个方块 每个方块有一个值 并且是堆起来稳定的 一个方块可以拿掉当且仅当剩下的还是稳定的 双方轮流拿 从左到右放组成一个m进制的数
#include
#include
#include
#include
#include
#include
using namespace std;
const __int64 mod = 1000000009;
struct...
分类:
其他好文 时间:
2015-03-03 13:36:37
阅读次数:
109
Problem Description
Let's design a new chess game. There are N positions to hold M chesses in this game. Multiple chesses can be located in the same position. The positions are constituted as a topological graph, i.e. there are directed edges connecting so...
分类:
其他好文 时间:
2015-03-01 13:14:04
阅读次数:
294
题意:有二个水壶,对水壶有三种操作,1)FILL(i),将i水壶的水填满,2)DROP(i),将水壶i中的水全部倒掉,3)POUR(i,j)将水壶i中的水倒到水壶j中,若水壶 j 满了,则 i 剩下的就不倒了,问进行多少步操作,并且怎么操作,输出操作的步骤,两个水壶中的水可以达到C这个水量。如果不可能则输出impossible。初始时两个水壶是空的,没有水。
简单题目,纯属练习。。。跟这个类似的...
分类:
其他好文 时间:
2015-02-28 23:04:34
阅读次数:
237
题目大意:根据给出的数字串求较大的最小回文串 简单题,可以从中间开始比较,如果左边大于右边的话则终止,若右边大于左边的话则中间+1,然后向左边推。输出时按左边复制一遍。#include#includeint t,i,j,l,r,n,pd,q,mid;char s[1000005];int main(...
分类:
其他好文 时间:
2015-02-24 22:08:52
阅读次数:
200
Given a connected undirected graph, tell if its minimum spanning tree is unique.
Definition 1 (Spanning Tree): Consider a connected, undirected graph G = (V, E). A spanning tree of G is a subgraph of G, say T = (V', E'), with the following properties:
1...
分类:
其他好文 时间:
2015-02-23 15:33:46
阅读次数:
257
Problem Description
In China, foreign brand commodities are often much more expensive than abroad. The main reason is that we Chinese people tend to think foreign things are better and we are willing to pay much for them. The typical example is, on the Uni...
分类:
其他好文 时间:
2015-02-23 15:32:28
阅读次数:
231
Description为了使得大家高兴,小Q特意出个自认为的简单题(easy)来满足大家,这道简单题是描述如下:有一个数列A已知对于所有的A[i]都是1~n的自然数,并且知道对于一些A[i]不能取哪些值,我们定义一个数列的积为该数列所有元素的乘积,要求你求出所有可能的数列的积的和 mod 10000...
分类:
其他好文 时间:
2015-02-23 09:38:53
阅读次数:
187