摘要: //poj1056 immediate decodablity//AC of gcc#include <stdio.h>#include <string.h>#define SIZE 2000#define MAX_BIT_NUM 20#define MAX_LINES 20//bool is not supported by GCC#define bool int#define true 1#define false 0typedef struct input_string { char data[MAX_BIT_NUM]; int length;}input_str 阅读全文
posted @ 2013-06-02 23:41 xiaowenchao 阅读(231) 评论(0) 推荐(0) 编辑
摘要: //gcc AC:#include<stdio.h>#include<string.h>//stack related region//#define MAX_STACK_SIZE 101#define MAX_CHAR_NUM 71char backward[MAX_STACK_SIZE][MAX_CHAR_NUM];char forward[MAX_STACK_SIZE][MAX_CHAR_NUM];int index_bw;int index_fw;char read_cmd[10],read_url[MAX_CHAR_NUM];char currentURL[M 阅读全文
posted @ 2013-06-01 10:44 xiaowenchao 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 分析:2013!的六进制表示法尾部包含的0的个数意味着其因数分解中包含6的个数; 比如6!=6*5*4*3*2*1=(720)10进制=(3200)6进制,可见尾部包含2个0;深入分析:6=2*3,所以凡是因数分解中包含6的数一定能将6进一步分解为2和3,且2、3为质因数;所以,可以遍历1-2013的每个数N,求得所有N的质因数分解中包含的3的个数count,然后累加所有count即为最后结果。代码如下:int count_three(int N){ int count=0; while(N%3==0) { count++; N /= 3; ... 阅读全文
posted @ 2013-04-28 22:28 xiaowenchao 阅读(238) 评论(0) 推荐(0) 编辑
摘要: #include #include #include using namespace std;using namespace stdext;//acronym : LNSpair longest_norepeat_substring( string& str ){ hash_map char_index;//save the character and last postion it appears size_t currentStart = 0;//start position of the LNS size_t repeated_postion = 0;//the last pos 阅读全文
posted @ 2013-04-28 22:05 xiaowenchao 阅读(194) 评论(0) 推荐(0) 编辑
摘要: 转载自http://blog.sina.com.cn/s/blog_4ce0162301013v81.html题目:给定一个包含40亿个随机排列的顺序文件,找到一个不在文件中的32位整数,在有足够内存的情况下应该如何解决该问题?如果有几个外部的临时文件可用,但是仅有几百字节的内存,又该如何解决?(1)对于有足够内存的情况,完全可以采用位图存储的方法,详细内容看《编程珠玑》第一章。(2)Ed Reingold 给出了另外一种解法。 问题的关键是只要找到一个数字,那么我们把问题简化一下,给定一个文件,里头最多包含16个4bit的整数,找到一个不在文件中的4bit整数。假设这十个数是1 2 3 4. 阅读全文
posted @ 2013-04-25 11:15 xiaowenchao 阅读(686) 评论(0) 推荐(0) 编辑
摘要: 原书代码如下:#include <iostream>#include <math.h>#include <time.h>#define BITSPERWORD 32#define SHIFT 5#define MASK 0x1F#define M 100#define N 10000000int a[1+N/BITSPERWORD];void set(int i){ a[i>>SHIFT] |= (1<<(i & MASK));}void clr(int i){ a[i>>SHIFT] &= ~(1< 阅读全文
posted @ 2013-04-25 11:12 xiaowenchao 阅读(212) 评论(0) 推荐(0) 编辑
摘要: 自己写的,感觉做的很一般,但是0ms,注意数组并不是所谓最大20,我开的100,否则会Runtime Error。#include <stdio.h>#include <stdlib.h>int main(){ int n; int length,count;//count计数最后输出值 int p_element[100]; int r_position[100];//存储右括号在string中的位置 scanf("%d",&n); for(int i=0;i<n;i++) { int s_element[100]={0}; ... 阅读全文
posted @ 2012-06-12 16:56 xiaowenchao 阅读(127) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>#include <stdlib.h>#include <string.h>char h_month[19][7]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen", "yax","zac","ceh","m 阅读全文
posted @ 2012-06-11 21:04 xiaowenchao 阅读(213) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>#include <stdlib.h>#include <string.h>#define LENGTH 6 //小数的位数(含小数点) //将字符转化为数字 unsigned int change (char s[LENGTH], unsigned int s1[LENGTH - 1]){ int ss[LENGTH - 1]; //ss 放未逆置的整数 memset (ss, 0, sizeof(ss)); int k = 0 ; for (int i = 0; i < LENGTH && s[i 阅读全文
posted @ 2012-06-11 15:40 xiaowenchao 阅读(199) 评论(0) 推荐(0) 编辑
摘要: clcclearpath1='D:\格式转换\CMU_car_testing_images\car_images3\*.pgm';dir1=dir(path1); path_new='D:\格式转换\CMU_car_testing_images\car_images3\';for i=1:length(dir1) filename=dir1(i).name; I=imread([path_new,filename]); filename=strcat('C:\car_images3\',filename); filename_new=strcat 阅读全文
posted @ 2012-06-11 15:32 xiaowenchao 阅读(594) 评论(0) 推荐(0) 编辑