题目:http://icpc.ahu.edu.cn/OJ/Problem.aspx?id=517之前差分约束搞了一发,现在终于知道贪心了。对区间右端点排序,尽量从右端点取数。
数据比较小,n^2就行了。#include #include #include #include #include #inc...
分类:
其他好文 时间:
2014-06-11 08:21:10
阅读次数:
276
题目:Reverse a linked list from positionmton. Do it
in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m=
2 andn= 4,return1->4->3->2->5->NULL...
分类:
其他好文 时间:
2014-06-09 23:03:18
阅读次数:
254
//定义二维平面上的点struct Point{ int x; int y;
Point(int a=0, int b=0):x(a),y(b){}};bool operator==(const Point& left,
const Point& right){ return...
分类:
其他好文 时间:
2014-06-08 22:26:17
阅读次数:
357
原题地址:https://oj.leetcode.com/problems/sqrtx/题意:Implementint
sqrt(int x).Compute and return the square root
ofx.解题思路:实现开平方函数。这里要注意的一点是返回的时一个整数。通过这一点我们可...
分类:
编程语言 时间:
2014-06-08 21:04:38
阅读次数:
329
题目来源:Light OJ 1278 Sum of Consecutive Integers
题意:N拆分成连续整数和的方案数
思路:奇因数的个数
#include
#include
#include
#include
using namespace std;
//筛素数
const int maxn = 10000010;
bool vis[maxn];
int prime[10...
分类:
其他好文 时间:
2014-06-08 15:34:09
阅读次数:
295
题目来源:Light OJ 1251 Forming the Council
题意:若干了条件至少满足一个 求是否有方案 输出任意一种可能的方案 留下的人的个数
思路:2-SAT基础题
#include
#include
#include
using namespace std;
const int maxn = 100010;
int n, m;
vector G[maxn*2];...
分类:
其他好文 时间:
2014-06-08 08:15:18
阅读次数:
261
题目来源:Light OJ 1026 Critical Links
题意:输出桥
思路:模版
#include
#include
#include
#include
#include
using namespace std;
const int maxn = 10010;
struct Edge
{
int u, v;
Edge(){}
Edge(int u, int v):...
分类:
其他好文 时间:
2014-06-08 04:07:05
阅读次数:
235
题目来源:Light OJ 1291 Real Life Traffic
题意:最少添加几条边 可以使全图边双连通
思路:缩点 重新构图 答案就是(叶子节点数+1)/ 2
#include
#include
#include
#include
#include
using namespace std;
const int maxn = 10010;
struct Edge
{
i...
分类:
其他好文 时间:
2014-06-08 02:57:26
阅读次数:
276
题目:Given a linked list and a valuex, partition it
such that all nodes less thanxcome before nodes greater than or equal tox.You
should preserve the or...
分类:
其他好文 时间:
2014-06-07 20:35:55
阅读次数:
236
3595: [Scoi2014]方伯伯的OjTime Limit: 6 SecMemory
Limit: 256 MBSubmit: 102Solved:
54[Submit][Status]Description方伯伯正在做他的Oj。现在他在处理Oj上的用户排名问题。Oj上注册了n个用户,编号为1...
分类:
其他好文 时间:
2014-06-07 17:01:57
阅读次数:
870