码迷,mamicode.com
首页 >  
搜索关键字:spoj balnum balanced    ( 1777个结果
SPOJ Problem:Beehive Numbers
阅读题。。加上等差数列判断。。#include#includeint n,s;int main(){ while(scanf("%d",&n)&&n!=-1){ n--; if (n%6){printf("N\n");continue;} n/=3; ...
分类:其他好文   时间:2015-03-08 20:07:50    阅读次数:159
SPOJ Problem:Inversion Count
逆序对裸题。可以用树状数组做,但树状数组是以数据的大小为下标,时间复杂度为O(n log n)(n=max(a[i])),总体来说还是归并好一些。#include#includeint a[200005],b[200005],n,t;int i;long long ans;void count(in...
分类:其他好文   时间:2015-03-08 18:32:55    阅读次数:105
SPOJ Problem:He is offside!
http://www.spoj.com/problems/OFFSIDE/阅读题。。#include#includeint x,a,b,c,n,m,i;int main(){ while(scanf("%d%d",&n,&m)&&(n+m)){ a=b=c=100000; ...
分类:其他好文   时间:2015-03-08 17:02:41    阅读次数:142
SPOJ Problem:Bishops
在棋盘上尽可能地摆主教,要求互不攻击高精度,注意0和1。#include#includechar s[105];int l,i,j,a[105];int main(){ while(scanf("%s",&s)!=EOF){ l=strlen(s); memset(a,0,size...
分类:其他好文   时间:2015-03-08 15:44:18    阅读次数:181
LeetCode Convert Sorted Array to Binary Search Tree
1.题目Given an array where elements are sorted in ascending order, convert it to a height balanced BST.2.解决方案1 struct Node{ TreeNode* t; int l; int r; Node(vector &num, int l, int r)...
分类:其他好文   时间:2015-03-08 10:28:52    阅读次数:148
SPOJ Problem:A Game with Numbers
突然就看到SPOJ升级了,让我好不适应。。这一一道博弈论的题目,可以先前面暴力一下,易得小于十的为必胜态,十的时候必败,然后11到19又必胜,而且发现只要各位为零且这个数不为零就必败。再依次验证上百,上千的数。。#include#includeint n;int main(){ scanf("...
分类:其他好文   时间:2015-03-07 19:56:20    阅读次数:120
Balanced Binary Tree
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 ...
分类:其他好文   时间:2015-03-07 15:40:43    阅读次数:108
leetcode_108_Convert Sorted Array to Binary Search Tree
欢迎大家阅读参考,如有错误或疑问请留言纠正,谢谢 Convert Sorted Array to Binary Search Tree Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 这道题是二分查找树的题目,要把一个有序数组转换...
分类:其他好文   时间:2015-03-07 14:15:44    阅读次数:130
SPOJ Problem 1436:Is it a tree
给出一个图,求它是不是树。。首先,一个图如果是树那么边数就是点数-1,然后再判断所有点是否连通。这里可以用并查集搞一下。代码如下:#include#includeint f[10005],x,y,i,j,n,m;int getf(int s){return f[s]==s?s:f[s]=getf(f...
分类:其他好文   时间:2015-03-07 11:25:36    阅读次数:137
SPOJ Problem 11063:AP - Complete The Series (Easy)
已知数列的第三项,最后第三项和数列的和,求这个数列sum=(a1+an)*n/2=(a3+a(n-3))/2,所以可以知道n.又(a(n-3)-a3)/(n-5)=d,那么就可以得到数列了。#include#includeint t,i;long long n,sum,a,b,d,fi;int ma...
分类:其他好文   时间:2015-03-07 11:18:58    阅读次数:114
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!