首先先贴一下题目:Given a constant K and a singly linked list L, you are supposed to reverse the links of every K elements on L. For example, given L being 1→2...
分类:
其他好文 时间:
2014-12-18 13:31:49
阅读次数:
194
题目Reverse Integer通过率34.2%难度EasyReverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321click to show spoilers.Have you ...
分类:
其他好文 时间:
2014-12-18 13:30:17
阅读次数:
134
一个有序数组,没有重复数字,向右推进了几次,找出最小值。例如(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).直接遍历一次找到答案就没有意义了。之前做过类似的题目,不过我找不到具体的题号了。所以就随便搜了下Garnker的,知道是Search in Rota...
分类:
其他好文 时间:
2014-12-18 13:30:14
阅读次数:
140
【题目】
Given a string S and a string T, count the number of distinct subsequences of T in S.
A subsequence of a string is a new string which is formed from the original string by deleting some (...
分类:
其他好文 时间:
2014-12-18 12:03:46
阅读次数:
118
题目大意:给定一棵树,每个点有一个权值和一个颜色,多次改变一些点的权值和颜色,多次求一条路径上与起点和终点颜色相同的点的权值和以及权值最大值
每种颜色开一个线段树 动态开节点 每个点只建一条链 这样空间复杂度是O(nlogn)的
然后就正常树链剖分就行了
#include
#include
#include
#include
#include
#define M 100100
us...
分类:
其他好文 时间:
2014-12-18 12:01:17
阅读次数:
181
题目:求一个整数二进制表示1的个数
第一版:
思路:如果一个整数与1做与运算,结果为1,那么该整数最右边一位是1,否则是0;
int NumberOf1(int n)
{
int count = 0;
while (n)
{
if (n&1)//如果一个整数与1做与运算的结果是1,表示该整数最右边是1,否则是0;
{
count++;
}
...
分类:
其他好文 时间:
2014-12-18 10:31:00
阅读次数:
199
题目:给你一个由点组成的网格,再给一些连结相邻点的操作(横向、纵向),统计里面的正方形。
分析:模拟。直接用两个数组,记录横线和竖线,统计时枚举顶点扫描即可。
说明:先输出小的╮(╯▽╰)╭。
#include
#include
#include
#include
#include
#include
using namespace std;
int H[10][10];
in...
分类:
其他好文 时间:
2014-12-18 10:26:02
阅读次数:
181
题目大意:怎么分配n个任务到m个server上使得负载尽量平衡。思路:将任务从大到小排序,依次放入负载最小的那个server中。由于是spj 的缘故,所以能够使用这个贪心。比方数据6 27 5 3 3 3 3就会得到错误答案。#include #include #include #include #...
分类:
其他好文 时间:
2014-12-18 10:09:24
阅读次数:
195
题意:UVa 10820这两个题是同一道题目,只是公式有点区别。给出范围为(0, 0)到(n, n)的整点,你站在原点处,问有多少个整点可见。对于点(x, y), 若g = gcd(x, y) > 1,则该点必被点(x/g, y/g)所挡住。因此所见点除了(1, 0)和(0, 1)满足横纵坐标互素。...
分类:
其他好文 时间:
2014-12-18 06:48:18
阅读次数:
144
题目1042:Coincidence
时间限制:1 秒
内存限制:32 兆
特殊判题:否
提交:1689
解决:898
题目描述:
Find a longest common subsequence of two strings.
输入:
First and second line of each input case co...
分类:
其他好文 时间:
2014-12-18 01:42:32
阅读次数:
162