Single Number II
Given an array of integers, every element appears three times except for one. Find that single one.
Note:
Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?...
分类:
其他好文 时间:
2014-08-02 12:53:53
阅读次数:
289
题目大意是在一块M行N列的农场上种谷物,但是不希望彼此相邻(共用一条边),并且有些地方不能种植谷物,给定M,N(范围都不超过12)以及一些不能种谷物的位置,求出一共有多少种方法种谷物。
状态压缩DP,设dp(i, k) 为种到第i行时,第i行状态为k的总共方案数,可以知道dp(i, k) = ∑dp(i -1, k'),其中我们要判断彼此相邻的情况以及不能种植的情况即可。
#i...
分类:
其他好文 时间:
2014-08-01 23:08:32
阅读次数:
225
QuicksumTime Limit: 2 Seconds Memory Limit: 65536 KBA checksum is an algorithm that scans a packet of data and returns a single number. The idea is...
分类:
其他好文 时间:
2014-08-01 22:43:32
阅读次数:
333
对给的药水浓度进行排序,对于小于解毒药水浓度的可以直接加上它的体积,对每次混合后的药水浓度进行记录,
大于解毒药水浓度就输出,注意你求得是百分比还是百分数。。。
#include
#include
#include
#include
using namespace std;
int s[10005];
int main()
{
int a,i,n,m,k;
s...
分类:
其他好文 时间:
2014-08-01 19:59:32
阅读次数:
205
Description
The Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid money was spent on extra roads between villages some years ago. But the jungle overtakes roa...
分类:
其他好文 时间:
2014-08-01 16:14:51
阅读次数:
277
要吐血了,把k写成m,debug一个多小时,简直无情。。。
#include
#include
#include
#include
#include
#include
#define N 22222
using namespace std;
int a[N];
int sum[N];
int T;
int m,k;
int vis[N];
int sech(int mid)
{
int...
分类:
其他好文 时间:
2014-08-01 16:12:11
阅读次数:
223
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2414
Problem C
SAM I AM
Input: Standard Input
Output: Standard Output
The world is in gre...
分类:
其他好文 时间:
2014-08-01 13:51:41
阅读次数:
328
#include
#include
typedef struct QNode
{ //构造结点类型
int data;
struct QNode *next;
}*QueuePtr;
typedef struct
{ QueuePtr front;
QueuePtr rear;
}LinkQueue;
void CreateQueue(LinkQueue &Q);//创建队列
void E...
分类:
其他好文 时间:
2014-08-01 13:51:24
阅读次数:
212
#include
#include
#include
typedef struct
{ char *ch;
int length;
}HString;
void StrAssign(HString &T,char chars[]);
int get_next(HString T,int next[]);
void main()
{ HString T;
char chars[80];
in...
分类:
其他好文 时间:
2014-08-01 13:51:23
阅读次数:
229