传送门:Primes in GCD Table题意:给定两个数和,其中,,求为质数的有多少对?其中和的范围是。分析:这题不能枚举质数来进行莫比乌斯反演,得预处理出∑υ(n/p)(n%p==0).#pragma comment(linker,"/STACK:1024000000,1024000000"...
分类:
其他好文 时间:
2015-02-21 01:22:36
阅读次数:
252
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.这道题是要求把有序链表转为二叉搜索树,和之前那道Convert Sorted Ar...
分类:
其他好文 时间:
2015-02-18 08:24:13
阅读次数:
160
这是一道水题,就是让你把给出的两个数倒置后相加再倒回来,模拟一下就行。#includeint n,m,x,y,t;int main(){ for(scanf("%d",&t);t;t--){ scanf("%d%d",&n,&m); x=0;y=0; ...
分类:
其他好文 时间:
2015-02-17 16:30:21
阅读次数:
106
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.这道题是要将有序数组转为二叉搜索树,所谓二叉搜索树,是一种始终满足左 &num) { ret...
分类:
编程语言 时间:
2015-02-17 15:18:17
阅读次数:
201
欢迎大家阅读参考,如有错误或疑问请留言纠正,谢谢
Balanced Binary Tree
Given a binary tree, determine if it is height-balanced.
For this problem, a height-balanced binary tree is defined as a binary tree in which th...
分类:
其他好文 时间:
2015-02-17 10:24:07
阅读次数:
135
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.[Solution] 1 TreeNode *sortedListToBST(Li...
分类:
其他好文 时间:
2015-02-16 11:37:14
阅读次数:
126
嗯。。在SPOJ上刷的第二题。一开始不知道哪错了,后来发现i出现了两遍。。因为m#include#includeint n,i,j,t,m,k,tot;int a[100005],b[4000];int prime[40000];int shai(int s){ int i,j; mem...
分类:
其他好文 时间:
2015-02-14 22:31:29
阅读次数:
152
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.[Solution] 1 TreeNode *sortedArrayToBST(vector &num) ...
分类:
其他好文 时间:
2015-02-14 22:27:21
阅读次数:
220
这道题是树链剖分的裸题,正在学LCT,用LCT写了,发现LCT代码比树链剖分还短点(但我的LCT跑极限数据用的时间大概是kuangbin大神的树链剖分的1.6倍,所以在spoj上是850ms卡过的)。收获: 1、边转换成点(即若存在边(u,v),则新加一个点z代表边,将z连接u和v,z的点权就是(....
分类:
其他好文 时间:
2015-02-13 21:11:22
阅读次数:
291
传送门
线段树的区间查找最大最小值模板.
裸的线段树
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define ls u << 1
#define rs u << 1 | 1
#define lson l, mid, u << 1
#de...
分类:
其他好文 时间:
2015-02-12 22:51:10
阅读次数:
165