Fork me on GitHub

01 2013 档案
动态规划 最大子矩阵
摘要:问题描述:(具体见http://acm.hdu.edu.cn/showproblem.php?pid=1081)给定一个n*n(0<n<=100)的矩阵,请找到此矩阵的一个子矩阵,并且此子矩阵的各个元素的和最大,输出这个最大的值。Example:0 -2 -7 09 2 -6 2-4 1 -4 1-1 8 0 -2其中左上角的子矩阵:9 2-4 1-1 8此子矩阵的值为9+2+(-4)+1+(-1)+8=15。我们首先想到的方法就是穷举一个矩阵的所有子矩阵,然而一个n*n的矩阵的子矩阵的个数当n比较大时时一个很大的数字 O(n^2*n^2),显然此方法不可行。怎么使得问题的复杂度降 阅读全文
posted @ 2013-01-24 11:51 huashiyiqike 阅读(381) 评论(0) 推荐(0)
scanf特殊结束符
摘要:scanf读入非空格分隔的字符串和整形的混合类型问题今天在网上看到一个网友提问这样一个问题:C语言输入字符串和数字时如何用逗号隔开,比如输入zhang1,90要求把zhang1赋给一个字符数组把90付给一个INT的变量。刚开始只想到如果用scanf("%s,%d",name,&age); 这种方式肯定会出现问题,输入的数据肯定都会被赋值给字符串,整形数据肯定会是个随机数,因此给网友回答时说不要将字符串写在前面,来避免该问题。后来网友说肯定能实现,因此在网上查了一些资料,终于将该问题解决,如下:scanf("%[^,],%d",name,& 阅读全文
posted @ 2013-01-23 17:05 huashiyiqike 阅读(4812) 评论(0) 推荐(2)
笔记 字符串转数值
摘要:1、字符串转数值#include <stdlib.h>#include <stdio.h>void main( void ){ char a[100]="0023200"; long b=strtol(a,NULL,10); printf("%ld",b);} 阅读全文
posted @ 2013-01-23 13:40 huashiyiqike 阅读(172) 评论(0) 推荐(0)
WA 代理服务器
摘要:#include<iostream>#include<cstdio>#include<fstream>#include<cstring>#include<algorithm>bool cmp(int a,int b){ return a<b?0:1;}int main(){ freopen("in.txt","r",stdin); bool flag,end; char ser[1000][16],ip[5000][16];int begin,m,n,i,j,count,num;// 阅读全文
posted @ 2013-01-23 09:34 huashiyiqike 阅读(216) 评论(0) 推荐(0)
1月12日清华2000年题 教训总结
摘要:1 #include "stdio.h" 2 #include "stdlib.h" 3 #include "string.h" 4 #include <iostream> 5 using namespace std; 6 typedef struct student 7 { 8 int age,grade; 9 char a[100];10 }student;11 int main()12 {13 int n,i,visit[10000],min,record,j;14 student *s=(student*)mall 阅读全文
posted @ 2013-01-12 09:24 huashiyiqike 阅读(174) 评论(0) 推荐(0)