自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(56)
  • 收藏
  • 关注

原创 328. Odd Even Linked List

问题:单链表位于奇数位置的统一放在前面,位于偶数位置的统一放在后面Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in

2016-01-26 15:08:36 425

原创 UVa 127 Accordian Patience

import java.io.File;import java.io.FileNotFoundException;import java.util.LinkedList;import java.util.Scanner;class Stack{ private LinkedList storage = new LinkedList(); public Stack(String str

2015-11-08 16:04:59 350

原创 UVa 572 Oil Deposits

#include#define SIZE 110int ROW, COL;int dx[8] = {0,1,1,1,0,-1,-1,-1};int dy[8] = {1,1,0,-1,-1,-1,0,1};char map[SIZE][SIZE];int visited[SIZE][SIZE];void dfs(int row, int col){ if(visited[

2015-10-13 23:25:43 287

原创 UVa 439 Knight Moves

#include#define N 8int vis[N][N];int step[N][N];int dx[8] = {1,2,2,1,-1,-2,-2,-1};int dy[8] = {2,1,-1,-2,-2,-1,1,2};int bfs(int x, int y, int target){ int front = 0, rear = 0, u, d; in

2015-10-10 23:51:32 335

原创 UVa 699 Falling Leaves

#include#define HASHSIZE 20000typedef struct TreeNode{ int val; int pos; struct TreeNode* left; struct TreeNode* right;}Node;int arr[HASHSIZE];int hashmap[HASHSIZE];int ans[HAS

2015-10-09 10:20:04 336

原创 UVa 712

1.用完全二叉树#include int order[10];int fulltree[2000];int ans[10];char str[2000];int calculate(char* str, int n){ int i; int p = 0; for(i = 0; i < n; i++) { if( str[order[i

2015-10-01 10:14:38 357

原创 UVa 548 Tree

import java.io.*;import java.util.*;class Node { int val; Node left; Node right; public Node(int val) { this.val = val; }}public class Main { static Integer[] inorder; static Integer[

2015-09-30 15:26:08 384

原创 UVa 297 Quadtrees

四分树的一个不一样的思路——单纯的递归实现#include int board[32][32];char str[20000];void giveblack(int length, int left, int up){ int i, j; for(i = up; i < up + length; i++) for(j = left; j < left+

2015-09-30 14:20:20 424

原创 Problem 1002

import java.io.*;import java.util.*;public class Main {public static void main(String[] args) {Scanner cin  = new Scanner(System.in);int n = cin.nextInt();for(int i = 1; i St

2015-09-12 12:57:23 410

原创 实现huffman编码的小程序

import java.util.ArrayList;import java.util.Collection;import java.util.Collections;import java.util.Comparator;import java.util.HashMap;import java.util.Iterator;import java.util.LinkedList;im

2015-09-08 15:33:28 435

原创 关于divide and conquer的两道Leetcode

贴上两道感觉很像的leetcode题目,第一道并不是自己独立写出来的,但是第二道因为对第一道的总结而一遍AC,开心~!返回一个集合时,要比较注意arraylist们都是在哪里声明的,在哪里添加的。Unique Binary Search Trees IIQuestion:Given n, generate all structurally unique BST's (b

2015-09-05 11:20:46 494

原创 算法竞赛入门经典第六章

6.1.1 卡片游戏C++ STL 队列的相关操作入队  q.push(x)出队  q.pop()访问队首  q.front()访问队尾  q.back()判断队列空  q.empty()队列中的元素个数  q.size()#include#includeusing namespace std;queue q;int main(){

2015-08-17 14:08:05 673

原创 Notes2

UVa 340#include #define MAX 1020int main(){ int n, i, cas = 1; int code[MAX], guess[MAX], hash1[20], hash2[20]; while(1) { scanf("%d", &n); if(!n) break; f

2015-08-12 22:16:35 339

原创 Notes

Uva 10055#include int main(){ unsigned long int a, b, c; while(scanf("%lu%lu", &a, &b) == 2) { c = a > b ? a - b : b - a; printf("%lu\n", c); } return 0;}sum

2015-08-11 16:46:34 384

原创 算法竞赛入门经典第五章

例 5.1.3 周期串fgets(str, MAX, stdin);scanf("%s",str);fgets()函数执行后,str会读到‘\n’符号停下,也就是提取一行,‘\n’也被读进字串,因此strlen(str)会比原本输入的字符串多一个;除了一种很特殊的情况,读入一行时,只一行并不是以’\n‘结束,而是以EOF结束。scanf()遇到’\n‘,space,tab就会停下,而

2015-08-10 19:27:33 604

原创 算法竞赛入门经典第三章

习题3-4 计算器(calculator)#include int main(){ int n1,n2; char f; scanf("%d %c%d",&n1,&f,&n2); switch(f) { case '+': printf("%d", n1 + n2);break; case '-': printf("%

2015-08-09 11:36:51 315

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除