HDU 3065,模板(备忘录)#include#include#include#include#includeusing namespace std;#define M 2222222char sx[1111][128];int n;char s[M];struct Trie{ ...
分类:
其他好文 时间:
2014-07-08 22:48:34
阅读次数:
192
线段树应用:
有一个数列,初始时为 a1,a2,… aN (N
1) 将 ai 的值加上 val ;
2) 对于一个区间[l,r],该区间的和。
3) 对于一个区间[l,r],求该区间的最大值。
数据结构:
//Node Type
struct Node{
int left, right;
int max, sum;
} tree[maxn];
/*
tree[k]'...
分类:
其他好文 时间:
2014-07-08 21:31:33
阅读次数:
237
代码注释比较详细:
#include
#include
using namespace std;
struct Node{
int data;
Node* next;
};
Node* head = NULL;
bool create() {
head = (Node*)malloc(sizeof(Node));
if(NULL == head) return false;...
分类:
其他好文 时间:
2014-07-08 21:05:05
阅读次数:
238
题目链接:uva 1363 - Joseph's
Problem
题目大意:给定n,k,求∑i=1n(k%i).
解题思路:参考别人的,自己想了很久,详细题解
#include
#include
#include
#include
using namespace std;
typedef long long ll;
ll solve (ll n, ll k) {
...
分类:
其他好文 时间:
2014-07-08 19:53:22
阅读次数:
139
旋转可以分为n种置换,对应的不同等价类分别是gcd(n,i)个i=0时不动,有n个
翻转分为奇偶讨论,奇数时有n种置换,每种有n/2+1个
偶数时有n种置换,一半是n/2+1个,一半是n/2个
#include
#include
#include
#include
#include
#include
using namespace std;
typedef long long ll;...
分类:
其他好文 时间:
2014-07-08 19:05:15
阅读次数:
163
区间颜色不一致就更新到底,否则lazy标记
#include
#include
#include
#include
using namespace std;
#define lc l,m,index<<1
#define rc m+1,r,index<<1|1
#define N 100005
#define ll __int64
struct node
{
bool same;
ll c...
分类:
其他好文 时间:
2014-07-08 18:00:56
阅读次数:
226
1.先序遍历非递归算法
#define maxsize 100
typedef struct {
Bitree Elem[maxsize];
int top;
} SqStack;
void PreOrderUnrec(Bitree t) {
SqStack s;
StackInit(s);
p=t;
while (p!=...
分类:
其他好文 时间:
2014-07-08 17:13:18
阅读次数:
267
通用标签和控制标签
第一部分;代码
//前端
Insert title here
访问属性
/tags.action?username=u&password=p">tags
//struct.xml
/tags.jsp
//类包
package com.struts2.tags;
import com.opensymphony.xwork2.Action...
分类:
Web程序 时间:
2014-07-08 16:21:33
阅读次数:
251
C语言中的函数指针
函数指针的概念: 函数指针是一个指向位于代码段的函数代码的指针。
函数指针的使用:
#include
typedef struct (*fun_t) (int,int);
fun_t pf;
int add(int a, int b)
{
return a+b;
}
int sub(int a,int b)
{
retu...
分类:
编程语言 时间:
2014-07-08 14:40:05
阅读次数:
217
题目链接:uva 10831 - Gerg's
Cake
题目大意:给定a和p,p为素数,问说是否存在x,使得x2≡a%p
解题思路:勒让德记号,判断ap?12≡1%p
#include
#include
#include
using namespace std;
typedef long long ll;
ll pow_mod (ll a, ll n, ll mod)...
分类:
其他好文 时间:
2014-07-08 13:48:57
阅读次数:
146