自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

XiaoCao's blog

I prefer thinking and imaging than doing. I am looking for principles and truth.

  • 博客(64)
  • 资源 (1)
  • 收藏
  • 关注

原创 主题提取On聊天群

主题提取On聊天群Idea应用场景实施场地Idea对于聊天群,当给出一个话题后,有非常多的发言者,几分钟消息就可以达到几百条,能否用算法提取出这几百条消息的重点信息:(1)话题:What they are talking about?(2)不同的看法:How many different ideas here, what they are and how many people hold each idea.应用场景不是特别重要的兴趣群,比如太极拳交流群,新生讨论群,英语学习群,办公支持群。这

2020-07-27 17:24:14 133

原创 10038 - Jolly Jumpers

题目https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=30&problem=979&mosmsg=Submission+received+with+ID+17410928 解题思路 1. 模拟题 2. 用hash判断diff(1~n-1) 3. 注意

2016-05-24 21:39:37 461

原创 10267 - Graphical Editor

题目https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=29&problem=1208&mosmsg=Submission+received+with+ID+17405109 解题思路模拟题,F命令用广搜加入候选pixel时,用hash判断是否已经在队列里

2016-05-23 19:50:31 382

原创 10196 - Check The Check

题目Time limit: 3.000 secondsYour task is to write a program that reads a chess board configuration and answers if there’s a king under attack (i.e. “in check”). A king is in check if it’s in a square wh

2016-05-20 14:59:54 539 1

原创 10033 - Interpreter

题目10033 - Interpreter Time limit: 3.000 secondsA certain computer has 10 registers and 1000 words of RAM. Each register or RAM location holds a 3-digit integer between 0 and 999. Instructions are enco

2016-04-28 19:37:14 412

原创 10137 - The Trip

题目10137 - The Trip Time limit: 3.000 secondsA number of students are members of a club that travels annually to exotic locations. Their destinations in the past have included Indianapolis, Phoenix, Na

2016-04-28 17:40:39 306

原创 706 - LC-Display

题目Time limit: 3.000 secondspdf题目解题思路1.把一个数字看成是5*3的矩阵,提前算好10个数字的打印模式,最后根据输入一行一行地输出2.设n是打印数值的位数,那么时间复杂度是Θ(n),空间复杂度是O(1)通过代码#include#includebool h1[10]={1,0,1,1,0

2016-04-25 09:30:10 283

原创 10142 - Australian Voting

题目Time limit: 3.000 secondspdf题目解题思路1.模拟题,一定要小心,把题意搞明白,并且把输入的各种情况都想清楚了再写代码2.所有的细节都在代码里了,我已经将代码弄的极简洁极易懂了3.当有人被淘汰出局时,不能把这些票加到现有的候选者上,必须重新计算(不能只修改某些现有的候选者的票数)。道理很简单但却不明显,一个出错的

2016-04-09 22:25:34 444

原创 10189 - Minesweeper

题目Time limit: 3.000 secondspdf题目解题思路1.这里不涉及什么技巧,用循环不断加即可,注意越界2.需要注意的是输入和输出格式。输入的时候最好用scanf,它以空白字符作为结束符;输出的时候注意空格:答案之间有空格,但是最后一个答案之后不能有空格,否则会错。提交的两次错误都在输出格式上通过代码#i

2016-03-25 10:42:49 311

原创 100 - The 3n + 1 problem

题目Time limit: 3.000 secondspdf题目解题思路1.这里不涉及什么技巧,用循环不断迭代即可2.对于一个正整数n,不知道它迭代的次数是多少,所以整个问题的时间复杂度没办法知道,但可以表示成Θ((i-j)*一次迭代的时间复杂度)通过代码#includeint main(){ int i,j,I

2016-03-24 12:42:32 285 1

原创 11729 - Commando War

解题思路1.将两个数组进行升序排序,这里的数据规模为20000,所以需要n^2以下的复杂度2.排好序之后,将两个数组从小到大进行匹配,这里的算法思想是贪心,可以证明这样做是正确的3.写代码时,主要不要混用C和C++,UVa的judge对此比较严格4.算法的时间复杂度是O(nlogn+mlogm),空间复杂度是O(n+m

2016-03-21 18:25:29 305 1

原创 11292 - Dragon of Loowater (Time limit: 1.000 seconds)

题目解题思路1.将两个数组进行升序排序,这里的数据规模为20000,所以需要n^2以下的复杂度2.排好序之后,将两个数组从小到大进行匹配,这里的算法思想是贪心,可以证明这样做是正确的3.写代码时,主要不要混用C和C++,UVa的judge对此比较严格4.算法的时间复杂度是O(nlogn+mlogm),空间复杂度是O(n+m

2016-03-19 09:51:20 420 2

原创 1388 - Graveyard (Time limit: 3.000 seconds)

题目:Programming contests became so popular in the year 2397 that the governor of New Earck — the largest human-inhabited planet of the galaxy — opened a special Alley of Contestant Memories (ACM) at the

2016-03-14 09:39:09 382

原创 Longest Common Prefix

题目Write a function to find the longest common prefix string amongst an array of strings.解题思路首先选出一个字符串作为标准,然后注意细节。代码public class Solution{ public String longestCommonPrefix(String[] strs){

2015-11-01 19:04:03 348

原创 Regular Expression Matching

题目Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire

2015-11-01 18:19:55 354

原创 Container With Most Water

题目Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0).

2015-10-11 04:50:01 447 4

原创 Integer to English Words

题目Convert a non-negative integer to its english words representation. Given input is guaranteed to be less than 231 - 1.For example,123 -> "One Hundred Twenty Three"12345 -> "Twelve Tho

2015-10-10 20:37:40 464

原创 Integer to Roman

题目Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.解题思路从低位到高位分解数的每一位,然后用罗马字符串表示该位上的数,需要注意的是每次都从串头插入。因为输入数据的取值范围很小,所以可以把每位

2015-10-09 15:27:09 256

原创 Roman to Integer

题目Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.解题思路组成罗马数字的字符一共有7个,均是大写的。I=1,V=5,X=10,L=50,C=100,D=500,M=1000出现一次加一次

2015-10-09 14:48:32 228

原创 8. String to Integer (atoi)

题目Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible

2015-09-22 01:13:28 286

原创 9.Palindrome Number

题目Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of c

2015-09-20 20:43:38 301

原创 6.ZigZag Conversion

题目The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA

2015-09-20 16:37:38 230

原创 4. Median of Two Sorted Arrays

题目There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).解题思路这道题应该有更简洁的方法,我的

2015-09-20 14:14:02 353

原创 5.Longest Palindromic Substring

题目Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.解题思路1.使用

2015-09-16 13:13:11 374

原创 7.Reverse Integer

题目Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321click to show spoilers.Have you thought about this?Here are some good questions to ask

2015-09-15 23:11:51 418

原创 3.Longest Substring Without Repeating Characters

题目Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3

2015-08-17 02:52:15 643

原创 2.Add Two Numbers

题目You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it a

2015-08-16 23:54:15 604

原创 1.Two Sum

题目Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the targe

2015-08-16 01:04:28 911

原创 C语言实现Luhn 校验

LUHN算法,主要用来计算信用卡等证件号码的合法性。1、从卡号最后一位数字开始,偶数位乘以2,如果乘以2的结果是两位数,将两个位上数字相加保存。2、把所有数字相加,得到总和。3、如果信用卡号码是合法的,总和可以被10整除#include #include #include int main(int argc, const char * argv[]

2015-07-31 16:01:35 1978

原创 VC++6.0的一个bug

VC++6.0是一个非常老的IDE,安装经常出现问题,特别是在win7上。4年前,我开始学习C语言,用的就是它,一直用到现在,估计它也应该寿终正寝了!对于for循环中的变量作用域,VC++6.0有一个bug,如下:for循环头部定义了int i,而for语句之前也定义了int ifor循环头部定义了int i,而for语句之后再定义int i

2015-04-29 16:35:16 748

原创 C语言中的static

原理C语言中的static可用来改变变量的作用域和生存期以及函数的作用域,该关键字可以用来修饰函数的定义和声明,以及变量的定义。用static修饰函数定义,表示该函数只在本文件有效(定义所在的文件),其它文件对该函数不可见。用static修饰函数外的变量定义,表示该变量只在本文件有效(定义所在的文件),其它文件对该变量不可见。用static修饰函数内的变量定义,表示该变量在多次

2015-04-29 16:13:49 652

原创 C语言中memset参数

函数原型void *memset(void *s, char ch, unsigned n);第一个参数居然是指针(地址)。

2015-03-30 11:30:47 916

原创 C语言程序块

#includeint main(){ { printf("a\n"); printf("b\n"); } return 0; }

2015-03-29 21:02:25 695

原创 C语言中的const变量初始化

C语言中的const变量在定义时必须初始化,如const int a=1;以后可以给这个const变量赋值,如a=2;但其值将不发生改变,一直都是初始化的值。

2015-03-27 08:55:23 2731 1

转载 中国佛学66句震撼世界的禅语(转贴)

原文地址:http://blog.sina.com.cn/s/blog_6f3ab4950100mla4.html(允许我先插两句,记得曲黎敏讲座里有那么一段,弟子问师祖:“您说是抄《金刚经》的人得道呢,还是背《金刚经》的人得道?”师祖答曰(哎呀我可真想卖个关子不告诉大家答案):“是照《金刚经》去做的人得道。”)1.人之所以痛苦,在于追求错误的东西。2.如果你不给自己烦恼,

2015-03-21 11:02:07 562

原创 怎样用函数初始化结构体

问题这里主要讨论函数的参数,应该是结构体呢,还是结构体的地址,还是二者都行。实验证明,只能用结构体的地址。代码#include#include#includetypedef struct { int a; //"int a=0;" is wrong int b[10]; }STU;void init_struct_point(STU *s){

2015-03-19 11:23:12 995

原创 数组的地址

代码/*************************************************************对于一个数组来说,比如int a[]a==&a==&a[0],这三个值是相等的,代表这个数组的起始地址*************************************************************/#include#incl

2015-03-19 10:44:36 828

原创 体验缓冲区溢出

缓冲区溢出:往程序的缓冲区写超出其长度的内容,也就是使用了申请之外的内存,会造成意想不到的结果。来看一个很小的例子,这个例子来自这里:http://zhan.renren.com/ilovecrack?from=template代码#includevoid main(){ int i=0; int a[]={1,2,3,4,5,6,7,8,9,10}; for(i

2015-03-16 20:23:31 556

原创 深搜解Riding the Fences

Riding the FencesFarmer John owns a large number of fences that must be repairedannually. He traverses the fences by riding a horse along each andevery one of them (and nowhere else) and fixing th

2015-03-16 19:34:34 677

转载 计算机界的传奇人物:高纳德

高纳德设置了一个悬赏游戏。如果有人挑出了他编写的TEX程序的错误,他就给挑错者奖励。第一个错误值2.56美元,第二个值5.12美元,第三个值10.24美元。据说,这张10.24美元的支票是他迄今为止为此签出的最后一张。     高纳德是美国计算机科学家唐纳德·克努斯(DonaldKnuth)的中文名。这位“现代计算机科学的鼻祖”是计算机界的传奇人物。他在 年仅36岁时就获得了图灵奖,成为该奖历

2015-03-15 10:36:57 6026

七桥问题大作业

哥尼斯堡七桥问题的总结研究,包含相关定理极其证明,另有现实应用

2014-02-28

空空如也

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

TA关注的人

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